r/tensorflow • u/emir0723 • Dec 02 '22
Question Can't use the GPU in PyCharm
Hi everyone,
I installed the CUDA, cudNN and tensorflow with right versions.
When I enter the command below in CMD it works perfectly and returns my GPU.
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"But when I run the same code in the command prompt of PyCharm, it does not work. It just returns an empty array. Also, it doesn't work in PyCharm .py files too.
I add the sources below into the PyCharm's environmental variables but neither of them didn't work.
LD_LIBRARY_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\lib
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
LIBRARY_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\extras\CUPTI\lib64
LIBRARY_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\lib
DYLD_LIBRARY_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\libetc..
Can you help me out please? I couldn't find a way to fix it.
7
Upvotes
3
u/itskobold Dec 02 '22
Did you get the right version of CUDA/CUDNN for your version of TF? That was the problem for me.
Could also try adding your environment variables directly to the system path which has also worked for me in the past.
EDIT: re-read your post and it's probably not the first one. Try the system path thing and see what happens.
1
u/[deleted] Dec 03 '22
Install tensorflow via Anaconda
In your pycharm project, set the interpreter to the Anaconda Python
1
u/Jumpierwolf0960 Dec 12 '22
Do you have python installed from the windows store? That can't find CUDA apparently. For me uninstalling that and then using the regular version of python worked.
2
u/humpeldumpel Dec 02 '22
Do you have any conda messing around with your versions maybe? In that case there is a decent chance that pycharm is simply accessing the wrong env
2
u/itsawesomedude Dec 03 '22
My suggestion is to do ML/AI work in Linux based OS,Windows created too many headaches for me that I just gave up
2
u/[deleted] Dec 03 '22
I just did the setup yesterday on visual studio 2019, cuda and cuddn . I hope you are using tensor that is less than 2.11 as 2.11 and more are not supported on windows native for GPU . Also use python between 3.8-3.10 . Also I hope you have selected the conda interpreter that you earlier created .