Getting Torch to recognize GPU - python

How do you get Torch to recognize CUDA on your video card?
I have a Nvidia GeForce GT 1030 running under Ubuntu 18.04, and it claims to support CUDA, yet when I first tested Torch with it by running:
virtualenv -p python3.7 .env
. .env/bin/activate
pip install torch
python -c "import torch; print(torch.cuda.is_available())"
it returned False, along with the warning:
The NVIDIA driver on your system is too old (found version 9010).
Please update your GPU driver by downloading and installing a new
version from the URL: http://www.nvidia.com/Download/index.aspx
Alternatively, go to: https://pytorch.org to install
a PyTorch version that has been compiled with your version
of the CUDA driver.
So I ran all system updates and used Ubuntu's proprietary driver installer to install the most recent Nvidia-435 driver for my card.
However, torch.cuda.is_available() still returns false, but now it doesn't give me any warning.
Have I mis-configured Torch or does my GPU just not support CUDA?

Nevermind. I spoke too soon. I didn't reboot after switching over the driver, and apparently that broke nvidia-smi and some other things that loaded the CUDA driver. After the reboot, Torch now recognizes CUDA 10.1 support.

Yeah I checked this link and the GT 1030 is not compatible.

Related

Pytorch detection of CUDA

Which is the command to see the "correct" CUDA Version that pytorch in conda env is seeing? This, is a similar question, but doesn't get me far.
nvidia-smi says I have cuda version 10.1
conda list tells me cudatoolkit version is 10.2.89
torch.cuda.is_available() shows FALSE, so it sees No CUDA?
print(torch.cuda.current_device()), I get 10.0.10 (10010??) (it
looks like):
AssertionError: The NVIDIA driver on your system is too old
(found version 10010)
print(torch._C._cuda_getCompiledVersion(), 'cuda compiled version') tells me my version is 10.0.20 (10020??)?
10020 cuda compiled version
Why are there so many different versions? What am I missing?
P.S
I have Nvidia driver 430 on Ubuntu 16.04 with Geforce 1050. It comes
with libcuda1-430 when I installed the driver from additional drivers tab in ubuntu (Software and Updates). I installed pytorch
with conda which also installed the cudatoolkit using conda install -c fastai -c pytorch -c anaconda fastai
In the conda env (myenv) where pytorch is installed do the following:
conda activate myenv
torch.version.cuda
Nvidia-smi only shows compatible version. Does not seem to talk about the version pytorch's own cuda is built on.

AssersionError: Torch not compiled with CUDA enabled

I want to run this repo. I installed everything that is needed for this project.
I have Windows 8.1 operating system, seems that I don't have NVIDIA GPU (from Device Manager: Display adapters - AMD Radeon HD 7660G + 7670M Dual Graphics and AMD Radeon HD 7670M).
I installed torch with command that is presented on Pytorch web-site
pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
But when I run the project I receive error - AssersionError: Tourch not compiled with CUDA enabled.
Then I tried to install torch with CUDA enabled.
pip install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
But when I run the project I receive error - AssersionError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from https://www.nvidia.com/Download/index.aspx.
Please, help me to solve my issue and run the project without errors.
I have already fixed this issue. There was a problem in source code where they use
opt.device
in main.py and violin_dataset.py. But this was declared as
opt.device = torch.device('cuda:0')
in config.py even if you didn't have cuda support.
So I changed it to
opt.device = torch.device('cpu')
And everything works fine now.

How could I run tensorflow on windows 10? I have the gpu Geforce gtx 1650. Can I run tensorflow on it? if yes, then how?

I want to do some ML on my computer with Python, I'm facing problem with the installation of tensorflow and I found that tensorflow could work with GPU, which is CUDA enabled. I've got a GPU Geforce gtx 1650, will tensorflow work on that.
If yes, then, how could I do so?
After opening the command prompt in administrator mode,the installation command for Tensorflow with GPU support is as follows:
pip3 install --upgrade tensorflow-gpu
To check if tensorflow has been successfully installed use command:
import tensorflow as tf
To test CUDA support for your Tensorflow installation, you can run the following command in the shell:
tf.test.is_built_with_cuda()
[Warning: if a non-GPU version of the package is installed, the function would also return False. Use this command to validate if TensorFlow was build with CUDA support.]
Finally, to confirm that the GPU is available to Tensorflow, you can test using a built-in utility function in TensorFlow as shown below:
tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)
Install tensorflow-gpu to do computations on GPU. You can use the code below to check whether your GPU is being used by tensorflow.
tf.test.is_gpu_available(
cuda_only=False,
min_cuda_compute_capability=None
)
Here are the steps for installation of tensorflow:
Download and install the Visual Studio.
Install CUDA 10.1
Add lib, include and extras/lib64 directory to the PATH variable.
Install cuDNN
Install tensorflow by pip install tensorflow
I don't think if you can.
https://www.tensorflow.org/install/gpu
Tensorflow clearly mentions the list of supported architectures and the 1650 sadly doesn't belong to the list. Check the "cuda enabled gpu cards" link on the website above.

Do I need to install CUDA driver for tensorflow-gpu manually if I install tf through conda

I followed this tutorial and installed tf-gpu using conda (https://www.pugetsystems.com/labs/hpc/The-Best-Way-to-Install-TensorFlow-with-GPU-Support-on-Windows-10-Without-Installing-CUDA-1187/) and it worked because I am seeing "...gpu:0" in my printed out log. Before I did the installation, I already have CUDA driver installed, so I am not sure.
Seems to me that conda install tensorflow-gpu comes with cuda toolkit and cuDNN,etc. I was wondering if installing CUDA driver is a require step. Another post I found did't mention driver either (https://towardsdatascience.com/tensorflow-gpu-installation-made-easy-use-conda-instead-of-pip-52e5249374bc). But the official GPU guide says it's required, so I am confused. I am doing it on Windows 10.
In my experience you do not need to install cuda or cudnn. Just your graphics driver is enough.
But depending on your system it might not be optimized. For that you would need to compile tensorflow from scratch and optimize it for your system.
Depends on the machine you are running on. For example, you can configure a Google Deep Learning VM to install the NVIDIA driver on startup.
If the driver is not installed, then follow the Tensorflow instructions on how to install the NVIDIA driver. Here are the instructions for Linux. Note that you only need to install the driver, and not the toolkit.

Error with tensorFlow

I have some problem with tensorFlow. I'm trying to install it with GPU on my manjaro linux with GTX 1060.
When I try to import tensorFlow in python with:
import tensorflow as tf
I get this error:
{...} ImportError: libcublas.so.8.0: cannot open shared object file:
No such file or directory {...}
With pip, I have installed tensorFlow-gpu:sudo pip install tensorflow-gpu
When I try to install cuda-8.0 (with pacaur -Syu cuda-8.0), after a very long loading, I got an error. Now when I try to install it, it does this:
Errors occurred, no packages were upgraded
Even if it's not on my pacaur list, and there is no reinstalling signed
I have install Keras with: sudo pip install Keras
I have install cudNN with: pacaur -Syu cudnn
I have installed my nvidia driver with (if I remember it right):pacaur -Syu nvidia
I am not familiar with manjaro. Assume you wanna install TensorFlow 1.4, the order would be:
Install latest Nvidia driver (version 384.xx or higher). Check its status in a terminal with nvidia-smi.
Install CUDA 8.0 without the GPU driver (as you have done it in step 1).
Add PATH=/usr/local/cuda-8.0/bin to the environment (in Ubuntu it's /etc/environment).
Added driver and CUDA paths to LD_LIBRARY_PATH. In Ubuntu, it is done by adding export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:/usr/local/cuda/lib64:/usr/lib/nvidia-384:/usr/local/cuda/extras/CUPTI/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} to /etc/bash.bashrc. At this point, you should be able to check CUDA version by nvcc --version.
Copy CUDNN files to somewhere and add that path to LD_LIBRARY_PATH. CUDNN needs no installation.
Install TensorFlow 1.4.
If you wanna install other versions of TensorFlow, you need to first check the supported versions of CUDA and CUDNN.
Hope this helps.

Categories

Resources