The code appears: No module named 'torch_geometric'

This is caused by the fact that there is no torch_geometric library, but it cannot be installed like a normal library with 'pip install library name' or 'conda install library name', and errors are often reported!!!

You need to install four widgets before installing torch_geometric. The specific installation steps are as follows:

Step 1: Check the pytorch and cuda versions installed in your environment

Taking my case as an example, my pytorch is 1.6.0 and cuda is 10.1
Insert image description here

Step 2: Enter the corresponding version to download the four widget whl files

Click to enter the link https://pytorch-geometric.com/whl/ as shown below.
Insert image description here
According to the information I checked in the first step, select 'torch-1.6.0+cu101' to enter:
Insert image description here
choose the one that suits you and download the four widgets. My environment python is 3.8, and I have chosen the highest version, as follows Four:
Insert image description here

step 3: Install the four widgets in the following order

pip install torch_cluster-1.5.9-cp38-cp38-linux_x86_64.whl
pip install torch_scatter-2.0.6-cp38-cp38-linux_x86_64.whl
pip install torch_sparse-0.6.9-cp38-cp38-linux_x86_64.whl
pip install torch_spline_conv-1.2.1-cp38-cp38-linux_x86_64.whl

As shown below, the installation is successful!
Insert image description here

step 4: Install torch_geometric

pip install torch_geometric

Output:
Insert image description hereInstallation successful! ! !

The solution in this article is borrowed from the blog: https://blog.csdn.net/weixin_47779152/article/details/120570367

Running the code still reports the error "No module named 'torch.profiler"

The above installation is successful. When running the code, the following error is reported:
Insert image description here
After checking the information, it is generally said that the pytorch version is low and needs to be improved! I also checked, and it seems that only torch1.10 and above versions have the torch.profiler library, but I don’t want to upgrade. Many libraries are basically installed according to the corresponding version. I am worried about other errors after upgrading the pytorch version! ! I continued to look for materials and finally found a solution on this website: https://www.cnblogs.com/dive-into/p/16953369.html

Specific steps:

  • Find the profile.py file according to the error path
  • Modify from torch.profiler import ProfilerActivity, profileto import torch.autograd.profiler, that is
    Insert image description here
  • Then re-run the code and the error is no longer reported. There is no problem with this library now! ! !

There may also be other questions. Specific issues will be dealt with on a case-by-case basis. Everyone is welcome to communicate together (^o^)/

Pay attention to collecting it in case you can't find it next time (^o^)/
Seeing that I worked so hard, give it a like and leave! !

Guess you like

Origin blog.csdn.net/weixin_43994864/article/details/132292340