安装pytorch geometric
Windows下配置不成功,编译库失败,转到Ubuntu成功编译。
Windows下配置Pytorch geometric的步骤:
- 安装vs2017或者2019,安装配置cuda,cudnn
- 还要装一个vc++14 Build tools,以编译下面的库 Install VC++14 from https://go.microsoft.com/fwlink/?LinkId=691126
- Install PYG: (Maybe you need to add –user) pip install –verbose –no-cache-dir torch-scatter pip install –verbose –no-cache-dir torch-sparse pip install –verbose –no-cache-dir torch-cluster pip install –verbose –no-cache-dir torch-spline-conv pip install plyfile pip install rdflib pip install torch-geometric
来自 https://github.com/rusty1s/pytorch_geometric/issues/633
比较顺利,按照步骤一步一步就行。
https://zhuanlan.zhihu.com/p/54389036
介绍一下在google Colab 云Python。。下配置PyG的步骤。
千万不要打开两个 Colab 页面,无法同时执行两个笔记本, 执行另外一个,那另一个笔记本内存全部清空!!!
注册Goole账号,在Google Drive 云盘里新建 Colab文件。
1 安装对应版本CUDA
改为GPU模式
貌似现在Colab自带Cuda了,可以通过!nvcc –version 查看cuda版本。
这里选择cuda9.2为例
12g内存 350g硬盘。。
!wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64 -O cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
!apt-get update
!apt-get install cuda
安装cuda9.2
!wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64 -O cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
!apt-get update
!apt-get install cuda
2 安装Pytorch
安装PyG
$ pip install –verbose –no-cache-dir torch-scatter $ pip install –verbose –no-cache-dir torch-sparse $ pip install –verbose –no-cache-dir torch-cluster $ pip install –verbose –no-cache-dir torch-spline-conv (optional) $ pip install torch-geometric
!pip install –verbose –no-cache-dir torch-scatter
!pip install –verbose –no-cache-dir torch-sparse
!pip install –verbose –no-cache-dir torch-cluster
!pip install –verbose –no-cache-dir torch-spline-conv
安装torch库的时候,需要用C++编译器编译,对版本要求高,所以windows下很难通过,需要安装对应的编译器版本和CUDA版本。
来自 https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
无痛安装。。。全程看进度条就可以
下载一下 https://github.com/rusty1s/pytorch_geometric
!git clone https://github.com/rusty1s/pytorch_geometric
运行一个例子:
可以运行,说明安装好啦。然后就可以造了。。
!pip3 install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp36-cp36m-linux_x86_64.whl
!pip3 install https://download.pytorch.org/whl/cu100/torchvision-0.3.0-cp36-cp36m-linux_x86_64.whl
!pip install –verbose –no-cache-dir torch-scatter
!pip install –verbose –no-cache-dir torch-sparse
!pip install –verbose –no-cache-dir torch-cluster
!pip install –verbose –no-cache-dir torch-spline-conv (optional)
!pip install torch-geometric
!git clone https://github.com/rusty1s/pytorch_geometric.git
这几行就可以装好Pyg了,每次用都要装一次,估计要花个10来分钟。
!git clone https://github.com/rusty1s/pytorch_geometric
下载文件 数据集等
!wget https://s3-eu-west-1.amazonaws.com/yc-rdata/yoochoose-data.7z
!dir
!7za x yoochoose-data.7z
然后解压, colab的IO性能比较弱,所以解压可能时间比较长
连接谷歌网盘
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL |
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} |
# 指定Google Drive云端硬盘的根目录,名为drive
!mkdir -p drive
!google-drive-ocamlfuse drive
复制文件到谷歌网盘
!cp -r /content/processed/yoochoose_click_binary_1M_sess.dataset /content/drive
colab 读入 google drive 的文件
2018年12月16日 11:14:58 code_nie 阅读数 2827
近段时间需要使用google colab训练一些神经网络,但是colab默认是不能读入google drive的数据的,每次都要重新上传,费时费力。所以这篇博客是让colab用户能够使用google drive的工作文件夹
2018年12月亲测有效。
step1
首先需要让colab获得google drive的授权,在google colab里执行如下代码:
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools !add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null !apt-get update -qq 2>&1 > /dev/null !apt-get -y install -qq google-drive-ocamlfuse fuse from google.colab import auth auth.authenticate_user() from oauth2client.client import GoogleCredentials creds = GoogleCredentials.get_application_default() import getpass !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL vcode = getpass.getpass() !echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
执行时会打印一个网址和一个授权码的输入框,此时你需要点击网址,登陆google account,授权colab使用你的google drive,然后系统会分配给你一个授权码,你需要将授权码粘贴到输入框里,回车继续。
若打印出success的信息,说明授权成功。
step 2
执行如下代码:
# 指定Google Drive云端硬盘的根目录,名为drive !mkdir -p drive !google-drive-ocamlfuse drive
此时colab中出现drive的文件夹,里面就是你的google drive的根目录文件
step3
然后更换执行的工作文件夹即可。
import os os.chdir(“drive/Colab Notebooks”)
来自 https://blog.csdn.net/code_nie/article/details/85029074