1. Solve the error ImportError: Failed to load PyTorch C extensions:
After installing torch and copying the torch-related files under "D:\py Anaconda\Lib\site-packages" to "D:\py Anaconda\envs\pychome\Lib\site-packages", an error occurs when running pychram" ImportError: Failed to load PyTorch C extensions:". (Note that the folder where I installed Anaconda is called "py Anaconda".)
This error does not mean that pytorch is installed incorrectly or that pytorch does not match the CUDA version. The reason for this error is that the python editor is not selected. Solution:
Step 1: File->Setting
Step 2: Click Python Interpreter
Step 3: Click the small gear in the upper right corner, then click add
Step 4: Click the following steps in the opened interface.
Step 5: Choose the correct python editor. Select "python.exe" under the Anaconda installation folder, and then click OK to succeed.
2. Solve the error RuntimeError: CUDA error: unknown error
Adding "torch.cuda.current_device()" to the line below import torch can solve the problem.