No CUDA device detected on cluster


I’m trying to execute a simple Python script to detect if the current installation correctly supports GPU. I will report here the procedure that I’ve followed. I have Python 3.6 installed using PyEnv and I’ve installed PyTorch using pip with the CUDA 8 version. The installation procedure is completed correctly without any errors. In the following you can find the code that I’ve written to check if PyTorch is able to detect the GPU devices:

import torch

def main():
    print("Testing CUDA PyTorch installation")
    print("Check available devices.")
    if torch.cuda.is_available():
        print("Using CUDA, number of devices = {}".format(torch.cuda.device_count()))
        print("Can't find CUDA!")

if __name__ == "__main__":

Unfortunately, despite on the node of the cluster nvidia-smicorrectly returns the usage statistics related to the GPU installed, my program returns this:

Testing CUDA PyTorch installation
Check available devices.
Can't find CUDA!

I obtain the same result with the version installed from sources. Do you have any ideas about how to solve this?

I’ve figured out the problem. You can ignore this!

Hey, I was having the same issue, but with spyder. Could I ask what you did to solve this problem?