Error:torch.cuda.is_available() return true in cmd but return false in pycharm

In cmd, I printed “import torch” then “torch.cuda.is_isavailable()”, it returned true;
but at python console in pycharm I got false.
I have set the right python interpreter, and there is ‘pytorch’ under the package menu. Are there any possible causes? Thanks in advance.

You are most likely using different Python environments and the one used in PyTorch might have installed the CPU-only binary.
Also, according to this topic the user claimed os.environ["CUDA_VISIBLE_DEVICES"]='1' was set somehow in Pycharm without manually setting it, which was hiding the only available GPU.

I see the python envirment I set is …\anaconda3\python.exe, you mean this is python2 but not python3? I see the environment in cmd is python 3.10 indeed.But what is CPU-only binary?

No, I meant different virtual Python environments which allow you to isolate installed packages.
“CPU-only” binary refers to the pip wheel or conda binary shipping with CPU kernels only without any CUDA kernels or CUDA libraries.

Thanks a lot. I find where is wrong. My pytorch Build is py3.9_cpu_0. I will uninstall it and try again.