Tensorflow for GPU without Conda not working - tensorflow

I wanted to use tensorflow for GPU for my current project so I followed a tutorial from youtube to install it without using conda (https://www.youtube.com/watch?v=-Q6SM_usn84)
I followed the tutorial and turns out there is no CUDA 11.2 for windows 11. Hence I installed the latest version i.e. CUDA 12 and followed the rest of the tutorial.
I then proceeded to create a virtualenv using python 3.10.10 and installed tensorflow using:
pip3 install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.11.0-cp310-cp310-win_amd64.whl
It did install successfully and imports but does not list my GPU as a physical device available.
After a bit of research I came across this "https://forums.developer.nvidia.com/t/how-do-i-install-cuda-11-0-on-windows-11-not-wsl2-windows-itself/192251" and reinstalled CUDA 11.2 for windows 10 in my windows 11 machine. Everything is still the same.
It imports but does not list my GPU as a physical device available.

Related

Tensorflow 1.15 cannot detect gpu with Cuda10.1

I have installed both tensorflow 2.2.0 and tensorflow 1.15.0(by pip install tensorflow-gpu==1.15.0). The tensorflow 2 is installed in the base environment of Anaconda 3, while the tensorflow 1 is installed in a separate environment.
The tensorflow 2.2.0 can recognize gpu based on a simple test:
if tf.test.gpu_device_name():
print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
//output: Default GPU Device: /device:GPU:0
But the tensorflow 1.15.0 can not detect gpu.
For your information, my system environment is python + cuda 10.1 + vs 2015.
The tensosflow versions 1.15.0 to 1.15.3 (the latest version) are all compiled against Cuda 10.0. Downgrading the cuda 10.1 to cuda 10.0 solved the problem.
Also be aware of the python version. It is recommended to install the tensorflow .whl file (as listed at https://nero-mirror.stanford.edu/pypi/simple/tensorflow-gpu/) for the specific python version. As for installation, see How do I install a Python package with a .whl file?
Tensorflow 1.15 expects cuda 10.0 , but I managed to make it work with cuda 10.1 by installing the following packages with Anaconda: cudatoolkit (10.0) and cudnn (7.6.5). So, after running
conda install cudatoolkit=10.0
conda install cudnn=7.6.5
tensorflow 1.15 was able to find and use GPU (which is using cuda 10.1).
PS: I understand your environment is Windows based, but this question pops on Google for the same problem happening on Linux (where I tested this solution). Might be useful also on Windows.
It might have to do with the version compatibility of TF, Cuda and CuDNN. This post has it discussed thoroughly.
Have you tried installing Anaconda? it downloads all the requirements and make it easy for you with just a few clicks.

Tensorflow will not run on GPU

I'm a newbie when it comes to AWS and Tensorflow and I've been learning about CNNs over the last week via Udacity's Machine Learning course.
Now I've a need to use an AWS instance of a GPU. I launched a p2.xlarge instance of Deep Learning AMI with Source Code (CUDA 8, Ubuntu) (that's what they recommended)
But now, it seems that tensorflow is not using the GPU at all. It's still training using the CPU. I did some searching and I found some answers to this problem and none of them seemed to work.
When I run the Jupyter notebook, it still uses the CPU
What do I do to get it to run on the GPU and not the CPU?
The problem of tensorflow not detecting GPU can possibly be due to one of the following reasons.
Only the tensorflow CPU version is installed in the system.
Both tensorflow CPU and GPU versions are installed in the system, but the Python environment is preferring CPU version over GPU version.
Before proceeding to solve the issue, we assume that the installed environment is an AWS Deep Learning AMI having CUDA 8.0 and tensorflow version 1.4.1 installed. This assumption is derived from the discussion in comments.
To solve the problem, we proceed as follows:
Check the installed version of tensorflow by executing the following command from the OS terminal.
pip freeze | grep tensorflow
If only the CPU version is installed, then remove it and install the GPU version by executing the following commands.
pip uninstall tensorflow
pip install tensorflow-gpu==1.4.1
If both CPU and GPU versions are installed, then remove both of them, and install the GPU version only.
pip uninstall tensorflow
pip uninstall tensorflow-gpu
pip install tensorflow-gpu==1.4.1
At this point, if all the dependencies of tensorflow are installed correctly, tensorflow GPU version should work fine. A common error at this stage (as encountered by OP) is the missing cuDNN library which can result in following error while importing tensorflow into a python module
ImportError: libcudnn.so.6: cannot open shared object file: No such
file or directory
It can be fixed by installing the correct version of NVIDIA's cuDNN library. Tensorflow version 1.4.1 depends upon cuDNN version 6.0 and CUDA 8, so we download the corresponding version from cuDNN archive page (Download Link). We have to login to the NVIDIA developer account to be able to download the file, therefore it is not possible to download it using command line tools such as wget or curl. A possible solution is to download the file on host system and use scp to copy it onto AWS.
Once copied to AWS, extract the file using the following command:
tar -xzvf cudnn-8.0-linux-x64-v6.0.tgz
The extracted directory should have structure similar to the CUDA toolkit installation directory. Assuming that CUDA toolkit is installed in the directory /usr/local/cuda, we can install cuDNN by copying the files from the downloaded archive into corresponding folders of CUDA Toolkit installation directory followed by linker update command ldconfig as follows:
cp cuda/include/* /usr/local/cuda/include
cp cuda/lib64/* /usr/local/cuda/lib64
ldconfig
After this, we should be able to import tensorflow GPU version into our python modules.
A few considerations:
If we are using Python3, pip should be replaced with pip3.
Depending upon user privileges, the commands pip, cp and ldconfig may require to be run as sudo.

tensorflow not supported wheel on this platform

I've searched around and non of the solutions seem to pertain to me, so here I am.
I installed anaconda 5.1 for python 3.6, I downloaded and installed 64-Bit(x86)Installer(551 MB)
from
https://www.anaconda.com/download/#linux
I followed the directions here
https://docs.anaconda.com/anaconda/install/linux
I had the install prepend the path and install microsoft VS code.
I then attempt to install the CPU only tensorflow using anaconda as suggested here
https://www.tensorflow.org/install/install_linux#InstallingAnaconda
I try to install the binary for python 3.6 CPU only
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.6.0-cp36-cp36m-linux_x86_64.whl
I get the following error
tensorflow-1.6.0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform.
I am running a Ubuntu 16.04 VM on windows 10.
edit: when I run this command
pip install --ignore-installed --upgrade tfBinaryURL
outside of the tensorflow environment it worked.
2nd edit:
Additionally I explored my tensorflow environment in my anaconda3 folder, and I noticed it only has python 2.7, so when I tried to install the cpu only tensorflow while in the enviroment for python 2.7 it worked.

Installing tensorflow-gpu 1.3.0 on windows 10

I have been trying to install tensorflow-gpu on windows 10, via
pip3 install --upgrade tensorflow-gpu
When I do this I break the current installation of ordinary tensorflow!, and get this error: On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error.
Somehow I manage to fix this by re-installing ordinary tensorflow, but then when I import tensorflow in python 3.5.2 and try to identify my GPU, No device is found!
I have a Cuda 9.0 installed alongside cudnn64_6 defined as a DLL in CUDA/v9.0/bin, and I can run the nbody test program without problems and I can see the GPU being used for that demo application.
Is there any known issue with tensorflow-gpu 1.3.0?
Really struggling on this. Why does it have to be so problematic installing this library!
Please help
mg
TensorFlow 1.3 (and 1.4) require CUDA 8.0 and do not support later versions. You will either need to downgrade CUDA to 8.0 or make a custom build from source.

is there a way to use tensorflow on windows 10 without slowing it down with a virtual machine?

I am using tensorflow currently on a virtualbox Linux VM, on a native windows pc.
This is slow.
I've read what I could find about this (e.g.: How to install TensorFlow on Windows?)
However, they suggest using a Virtual Machine, which is maybe 10 times slower compared to a native OS.
Is there a way to use Tensorflow just in windows directly?
Yes. We recently announced TensorFlow 0.12, which is the first version that comes with Windows support and pre-built packages for Windows. It supports Python 3.5 and GPU acceleration with GPUs that support CUDA 8.0. To install the Python package on Windows you can use pip:
C:\> pip install tensorflow
To install the GPU-acclerated version there is a different package:
C:\> pip install tensorflow-gpu