I tried to run my python code, however, I got this error:
/Users/Apple/anaconda3/bin/python /Users/Apple/Downloads/linear-regression.py
Traceback (most recent call last):
File "/Users/Apple/Downloads/linear-regression.py", line 39, in <module>
model.cuda()
File "/Users/Apple/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 258, in cuda
return self._apply(lambda t: t.cuda(device))
File "/Users/Apple/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 185, in _apply
module._apply(fn)
File "/Users/Apple/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 191, in _apply
param.data = fn(param.data)
File "/Users/Apple/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 258, in <lambda>
return self._apply(lambda t: t.cuda(device))
RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason. The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols. You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.
I am an old iMac (2011) I am not use that I have GPU on board… how can I check?
also, incase I don’t have GPUs, is there a way to emulate them? (for development and learning purpose)
I’ve never used a Mac, but apparently you can check it in “About this mac > More info > Graphics/Displays”.
If you have a suitable GPU, note that you would have to build PyTorch from source to get GPU support on a Mac.
You can find the build instructions here.
Also, I’m not familiar with emulating a GPU.
You could have a look at Google Colab, which provides a free GPU for your notebook for a certain amount of time.
Mac binaries do not ship with CUDA support. Moreover, from this page, it seems your machine don’t have a CUDA GPU anyways. However, your code calls model.cuda(). Hence the error.
Thanks for your message.
So I started the whole process over and was able to successfully build from source!!
I don’t know why it was not working before.
Maybe I missed a LD_LIBRARY_PATH :