Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering an issue with the TFT/DeepAR/LSTM,etc. model #1266

Closed
sdmishra123 opened this issue Feb 14, 2025 · 2 comments
Closed

Encountering an issue with the TFT/DeepAR/LSTM,etc. model #1266

sdmishra123 opened this issue Feb 14, 2025 · 2 comments
Assignees
Labels

Comments

@sdmishra123
Copy link

sdmishra123 commented Feb 14, 2025

Description

Hello Team,

I'm encountering an issue while running the Temporal Fusion Transformer (TFT)/ DeepAR/LSTM, etc. except for NBEATS/NHits models from the Neural Forecast package. Despite trying to force the model to run on CPU, the problem persists. Are there any alternative solutions or workarounds that I can explore to resolve this issue?

Best,
Sapna

**nf.fit(df=Y_train_df, val_size=val_size)

NotImplementedError: The operator 'aten::nanmedian.dim_values' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on pytorch/pytorch#141287 and mention use-case, that resulted in missing op as well as commit hash 2236df1770800ffea5697b11b0bb0d910b2e59e1. As a temporary fix, you can set the environment variable PYTORCH_ENABLE_MPS_FALLBACK=1 to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.**

Use case

No response

@sdmishra123 sdmishra123 changed the title Encountering an issue with the TFT model Encountering an issue with the TFT/DeepAR/LSTM,etc. model Feb 14, 2025
@jmoralez jmoralez transferred this issue from Nixtla/nixtla Feb 14, 2025
@marcopeix marcopeix self-assigned this Feb 14, 2025
@marcopeix
Copy link
Contributor

Hello! This not an issue related to neuralforecast, but related to running PyTorch code on a Mac. As the error suggests, some operations do not run on the MPS backend. So, you need to set PYTORCH_ENABLE_MPS_FALLBACK=1 as an environment variable.

In a notebook, you can run this as the first cell (very important that this cell is at the top of the notebook before anything else): %set_env PYTORCH_ENABLE_MPS_FALLBACK=1.

If you run a Python script, you can also do PYTORCH_ENABLE_MPS_FALLBACK=1 python main.py.

You can also do this before running your script:

export PYTORCH_ENABLE_MPS_FALLBACK=1

Or set it inside your Python script:

import os
os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1'

I hope this helps!

@sdmishra123
Copy link
Author

Oh, I see. I was initializing ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1' just before fitting the model and so the error was't fixed. Thanks! Appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants