has anyone been able to successfully run NeuralFor...
# general
n
has anyone been able to successfully run NeuralForecast on Apple Silicon leveraging GPU acceleration? i cannot get
tensorflow-metal
and
tensorflow
to play nice, even using aarm64 Docker image.
y
I have found this issue a few weeks ago with no solution for now. It just seems that pytorch is not finished implementing all the methods necessary for running properly with MPS. https://developer.apple.com/metal/pytorch/ https://github.com/Nixtla/neuralforecast/issues/709 The only thing that I I found that worked was to fall back to CPU using this:
import os
os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1'
at the beginning of your script.
👍 1
d
I used the same in a Jupyter notebook:
%env PYTORCH_ENABLE_MPS_FALLBACK=1
It looks like some functions still run on GPU and only fallback to CPU when they are not available with MPS
n
MPS?
d
"Metal Performance Shaders" is a collection of highly optimized compute and graphics shaders designed to integrate into apps using Apple's Metal API.
👍 1
n
any chance you can share your installation/setup? im having a lot of trouble with this. thanks
d
Sure, happy to help! I installed the following packages into a conda environment (first set from pip, second directly conda). Then I start a notebook in this environment and add the command I sent in my previous comment at the top of the notebook.
Copy code
[pip.deps]
juliapkg = ""
ipywidgets = ""
ipykernel = ""
neuralforecast = ""
mlforecast = ""
juliacall = ""

[deps]
scikit-learn = ""
pytorch = ""
pandas = ""
matplotlib = ""
statsmodels = ""
seaborn = ""
numpy = ""
You can probably skip the julia-related packages.
I am using Python 3.11
n
and then you just set
gpus=1
in your NF model definition and it automatically picks up the GPU with
PYTORCH_ENABLE_MPS_FALLBACK=1
?
d
I did not specify the
gpus
at all.
n
and why is conda crucial here? what does the environment get you? (other than just virtualization)
d
conda is not crucial; the environment setup guarantees that all dependencies relevant to this project are in a "sandbox" and there are not conflicts among other packages that may be installed in the global system/environment.
You could use different environment setups, e.g., venv, or even use the global/default environment, but I highly suggest against the latter.
n
ok good to know, thanks so much Dimitris
👍 1