Vscode configures pytorch
premise
pytorch has been installed through Anaconda Promp, and the test is successful, and vscode has also been installed.
Configure environment variables
Configure environment variables at both paths, the configuration method is as follows
and click OK.
Configure json in vscode
Open Vscode, click File>>Preferences>>Settings>>Extensions in the upper left corner, find python in the extension, click on the right to
modify the path in the red box below, and modify it to the location of python.exe in pytorch installed in Anaconda , it's normal to open it differently from mine, and make up for what's missing.
test
Remember to save the file and restart vscode. Create a py file and run the following code:
import torch
print(torch.cuda.is_available())
run successfully