My tests show that Tensorflow GPU operations are ~6% slower on Python 3 compared to Python 2. Does anyone have any insight on this?
Platform:
Ubuntu 16.04.2 LTS
Virtualenv 15.0.1
Python 2.7.12
Python 3.6.1
TensorFlow 1.1
CUDA Toolkit 8.0.44
CUDNN 5.1
GPU: GTX 980Ti
CPU: i7 4 GHz
RAM: 32 GB
When operating Tensorflow from python most code to feed the computational engine with data resides in python domain. There are known differences between python 2/3 when it comes to performance on various tasks. Therefore, I'd guess that the python code you use to feed the net (or TF python layer, which is quite thick) makes heavy use of python features that are (by design) a bit slower in python 3.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 months ago.
This post was edited and submitted for review 7 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I want to test run some finite-difference time domain (FDTD) simulations using parallelization on a GPU and compare the speed to CPU-based simulation runs. This is basically my very first attempt at using GPU acceleration for scientific computing.
My system configuration:
CPU: Intel Core i7-4930K # 3.40 GHz
GPU: Gigabte GeForce GTX 1650 OC LP 4.0 GB
RAM: 32.0 GB (16.0 GB usable)
OS: Windows 7 Home Premium 64-bit
This GPU has 896 CUDA cores and compute capability 7.5, so I'm expecting a significant acceleration when compared to running my simulation on "only" 12 CPU cores.
The simulation script uses the fdtd simulation package and I'm using Jupyter notebooks for convenience. If you're interested in some actual code reference, I can recommend taking a look at the short example scripts on the fdtd GitHub page.
I've installed the CUDA ToolKit version 10.2 as this appears to be the last version with Windows 7 support. Version 11.0+ appears to support Windows 10+ only, at least according to the download page (can anyone confirm this?).
I've also installed torch + torchvision + torchaudio, simply because PyTorch includes these packages during installation procedure. However, I got stuck when trying to install the Python CUDA ToolKit as it seems to require another package called nvidia-pyindex, which is not available for Windows. Moreover, I'm confused by the PyTorch installation command for CUDA 10.2 which says "CUDA-10.2 PyTorch builds are no longer available for Windows, please use CUDA-11.6", especially since they clearly state:
Supported Windows Distributions
PyTorch is supported on the following Windows distributions:
Windows 7 and greater; Windows 10 or greater recommended.
Windows Server 2008 r2 and greater
In the Python interpreter, I'm getting
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
False
and trying to set the CUDA backend in the simulation package returns
import fdtd
fdtd.set_backend("torch.cuda.float64")
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [3], in <cell line: 35>()
31 display(HTML("<style>.container {width:100% !important;}</style>"))
33 #fdtd.set_backend("numpy")
34 #fdtd.set_backend("torch.float64")
---> 35 fdtd.set_backend("torch.cuda.float64")
File C:\Program Files\Python38\lib\site-packages\fdtd\backend.py:376, in set_backend(name)
374 raise RuntimeError("Torch backend is not available. Is PyTorch installed?")
375 if name.startswith("torch.cuda") and not TORCH_CUDA_AVAILABLE:
--> 376 raise RuntimeError(
377 "Torch cuda backend is not available.\n"
378 "Do you have a GPU on your computer?\n"
379 "Is PyTorch with cuda support installed?"
380 )
382 if name.count(".") == 0:
383 dtype, device = "float64", "cpu"
RuntimeError: Torch cuda backend is not available.
Do you have a GPU on your computer?
Is PyTorch with cuda support installed?
How should I progress from here?
Unfortunately, there seems to be fairly little you can do with your current software stack - Windows 7 is going to become an increasingly larger pain in the butt as software progresses, especially GPU drivers. The simplest way would be to upgrade that to Windows 10.
If you really, really don't want to or can't switch, you could also look into dual-booting a Linux system on the same machine. That should get you some more flexibility for the NVIDIA driver.
edit: There may be another way to sidestep this - it's downgrading Pytorch, like I said before in the comments. According to the interactive table at https://pytorch.org/get-started/locally/#start-locally, PyTorch LTS 1.8.2 does support Windows 7 with CUDA 10.2, if you run it through Python 3.8, which I see you do. You can try installing that particular version with (found from that table):
pip3 install torch==1.8.2 torchvision==0.9.2 torchaudio===0.8.2 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cu102
Once you get that installed, you should of course verify it's running via GPU using the import torch; torch.cuda.is_available() you used earlier.
fdtd doesn't have a particular minimal version dependency on PyTorch, which usually means things might break - but there's a chance they won't.
Amazon sagemaker documentation
states that TensorFlow 2.3 Python 3.7 GPU Optimized kernel should be available to use when a sagemaker notebook instance is used. But when I use a ml.p2.xlarge (us-west-2) amazon sagemaker notebook instance I cannot see the TensorFlow 2.3 Python 3.7 GPU Optimized kernel
I can see other kernles such as
Python 3 (TensorFlow 2.1 Python 3.6 GPU Optimized)
Python 3 (MXNet 1.8 Python 3.7 GPU Optimized)
Do I need to enable some particular setting to see TensorFlow 2.3 Python 3.7 GPU Optimized kernel
The documentation you linked to says that the kernels are available in Sagemaker Studio. I suppose the Sagemaker notebook instances do no have the entire list of kernels that Studio has.
I'm tried many PC with different hardware capability to install tensorflow on gpu, they are either un-compatible or compatible but stuck in some point. I would like to know the minimum hardware required to install tensorflow-gpu. And also I would like to ask about some hardware, Is they are allowed or not:
Can I use core i5 instead of core i7 ??
Is 4 GB gpu enough for training the dataset??
Is 8 GB ram enough for training and evaluating the dataset ?? with most thanks.
TensorFlow (TF) GPU 1.6 and above requires cuda compute capability (ccc) of 3.5 or higher and requires AVX instruction support.
https://www.tensorflow.org/install/gpu#hardware_requirements.
https://www.tensorflow.org/install/pip#hardware-requirements.
Therefore you would want to buy a graphics card that has ccc above 3.5.
Here's a link that shows ccc for various nvidia graphic cards https://developer.nvidia.com/cuda-gpus.
However if your cuda compute capability is below 3.5 you have to compile TF from sources yourself. This procedure may or may not work depending on the build flags you choose while compiling and is not straightforward.
In my humble opinion, The simplest way is to use TF-GPU pre-built binaries to install TF GPU.
To answer your questions. Yes you can use TF comfortably on i5 with 4gb of graphics card and 8gb ram. The training time may take longer though, depending on task at hand.
In summary, the main hardware requirement to install TF GPU is getting a Nvidia graphics card with cuda compute capability more than 3.5, more the merrier.
Note that TF officially supports only NVIDIA graphics card.
You should find your answers here:
https://www.nvidia.com/en-gb/data-center/gpu-accelerated-applications/tensorflow/
From the link:
The GPU-enabled version of TensorFlow has the following requirements:
64-bit Linux
Python 2.7
CUDA 7.5 (CUDA 8.0 required for Pascal GPUs)
cuDNN v5.1 (cuDNN v6 if on TF v1.3)
I wrote some tensorflow code in python 3.6. Now I want to run my code on a workstation that uses the Nvidia GPU cloud docker (NGC) to utilize the GPU.
Unfortunately the Nvidia docker only supports python 3.5. Thus the main error is the string formatting (f"{}"). Does anyone know a workaround for this problem or do I have to change every string formatting in my code?
And does anyone have other problems in mind, when I downgrade my code to 3.5?
You could backport f literals using a package ww ( pip install ww ). Theoretically this should have been available in the future module however 3.5 is in maintenance mode status, and you can't add new major features on an existing release branch.
I have problems setting up tensorflow with python 3.5.3 on Windows 7. The CUDA version is 8.0 and the GPU driver is updated to the latest version.
On the machine I used, there are one Geforce titan z (two cores) and one 750ti installed on the machine. I kept getting error msgs saying the "peer access is not supported" between the two cores on the titan z card and between the titan z and 750ti.
I am wondering:
1. Is it possible to use only one GPU for the tensorflow, and let it work?
2. Is it possible to use both cores in the titan z card for tensorflow?
3. Any suggestions on the python version and anaconda version for tensorflow? Will a Linux environment solve these problems?
Thank you!
It is possible to use a single or multiple GPUs and specify which one to use for each operation (link). TensorFlow has a requirement of compute capability 3.5 for an eligible GPU. Python/linux environment doesn't affect how GPU is used.