安装CUDA12.1和torch2.2.1下的DKG

1.创建python虚拟环境

set NO_PROXY=*

conda deactivate
conda env remove -n findkg
conda create -n findkg python=3.11
conda activate findkg

conda install packaging setuptools
pip uninstall numpy
conda install numpy=1.24.3

请注意,DKG需要python>=3.11,一定要注意

2.下载cuda

https://developer.nvidia.com/cuda-12-1-0-download-archive

3.下载pytorch等安装包

conda install pytorch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 pytorch-cuda=12.1 -c pytorch -c nvidia

https://pytorch.org/get-started/previous-versions/

pip install torchdata
conda install -c dglteam/label/cu121 dgl
conda install pandas 

4.检验是否成功

import dgl
import torch
 
# 检查 DGL 和 CUDA 版本
print(f'DGL version: {dgl.__version__}')
print(f'CUDA available: {torch.cuda.is_available()}')
print(f'CUDA version: {torch.version.cuda}')

# 创建一个简单的图,并检查是否可以使用 CUDA
u = torch.tensor([0, 1, 2])
v = torch.tensor([1, 2, 3])
g = dgl.graph((u, v))
 
# 将图移到 GPU 上
g = g.to('cuda')
print(g)

CUDA Toolkit版本及可用PyTorch对应关系

5.安装DKG

5.安装DKG

  1. 在DKG目录下创建完整的setup.py:
from setuptools import setup, find_packages

setup(
    name="DKG",
    version="0.0.8",
    packages=find_packages(),
    install_requires=[
        "torch",
        "dgl",
        "numpy==1.24.3",
        "pandas",
        "scikit-learn",
        "tqdm"
    ],
    package_data={
        'DKG': ['*.*'],
    },
)

2.安装

pip install -e DKG

python -c "import DKG; print(DKG.__version__)"

你可能感兴趣的:(python)