I am using windows and pycharm, Pytorch is installed by annaconda3 (conda install -c perterjc123 pytorch). My python is 3.6.2 and pytorch installed is pytorch 0.3.0.
Do you have an NVIDIA GPU? Have you installed cuda on this NVIDIA GPU? If not, then pytorch will not find cuda. It is not mandatory, you can use your cpu instead. Every time you see in the code something like tensor = tensor.cuda(), simply remove that line and the tensor will reside on the CPU. The problem is that it will be incredibly slow to the point of being unusable.
You can also explicitly check by doing torch.cuda.is_available()
If it returns False, it means that CUDA is not available on your machine
Great thanks to your reply. I had GTX 1070 graphic card and it has GPU.
I followed the link to install cudatoolkit in python (https://developer.nvidia.com/how-to-cuda-python) and run the sample test successfully. However, torch.cuda.is_available() still shows False. It will be appreciated If you could tell me how to make CUDA work with torch.
for CUDA 9.0, otherwise conda install pytorch torchvision -c pytorch
Try removing it and installing it with these two commands. Otherwise you can try installing from source, check out the instructions on the pytorch github page.
As I said in the post, I use Windows with Annaconda3. Thanks for the two command lines. However, the package is not for Windows (package missing in current channels).
Ah, I see. Then have you tried installing it from source? Where did you find the windows package? Maybe you can ask the author to see if there is CUDA support
I just made it work now! I checked the developed post (https://github.com/pytorch/pytorch/issues/494), and some guy made it work and I installed it from his source. Only cuda80 works in my desktop. And also thanks for your reply!
Yes, you should install at least one system-wide CUDA installation on Windows when you use the GPU package. It’s recommended that you install the same version of CUDA that PyTorch compiles with. It will work even when the two versions mismatch. But you’ll then have to pay attention to the version of the GPU drivers.
Does PyTorch uses it own CUDA or uses the system installed CUDA?
Well, it uses both the local and the system-wide CUDA library on Windows, the system part is nvcuda.dll and nvfatbinaryloader.dll. They are located in the %systemroot%, so I’m afraid we could not put them in the package due to some potential permission issues. The reason why we use the local CUDA installation is to prevent dll load failure. e.g. Some users don’t have CUDNN installed. I don’t think the missing of any optional CUDA dependency should be a barrier to use our package on Windows.
Should pip install s take care of the CUDA or not?
No, at least the answer is no on Windows. We don’t use pip to install CUDA on Windows. We just use pip to select the package you want. For most users, it may be no differences using cuda80/cuda90. But if you are using some new or legacy cards, then you can only use specific CUDA distributions.
I’m not sure I understood all.
Could we get away with installing the CUDA Toolkit on Windows and have all installed by pip only for PyTorch?
I don’t need CUDA on my computer besides for PyTorch so I’d be happy if PyTorch could be independent and self sustained (All its dependencies supplied in the pip downloaded).
That’s nearly an impossible task. Did you read my post? Some DLLs are installed to the system directory. pip or any python package cannot do this. Because there are permission issues.
Well, I don’t know exactly the answer. Because I have never tried this before. But according to some posts, these two files will get updated with the Graphics driver. So the problem will become a little bit complex. For users that don’t have CUDA installed, I just don’t know if the DLLs will still work when drivers get updated. But we could try your suggestion because it doesn’t affect the users that have CUDA installed. See document from MSDN. Anyway, thanks for your suggestion.
Yep,
I think it is the right policy to take.
First try to make it work out of the box independent of anything.
If it works, you reduced the the level of frustration for new users.
In case of any issue with CUDA still the first step would be - Install the latest CUDA drivers.
I tried everything to only the following steps works: The cuda 10 is too new for my graphic card.
(1)go to previous version of cuda & pytorch here:
(2)following the page instruction and download *.whl file suitable for my python version and platform. for me it’s python 3.6 , windows
(3)install *.whl file
(4)test if torch.cuda.is_available() returns True