GitHub代码在colab运行记录(失败)
前情提要
项目是论文 Emotional Chatting Machine: Emotional Conversation Generation with Internal and External Memory 的代码
项目地址https://github.com/tuxchow/ecm
由于原项目需要
- Python 2.7
- Numpy
- Tensorflow 0.12
在colab上太难搞(对我而言),所以找了高版本替代 ECM-tf
该项目需要
- Python 3.5
- Tensorflow 1.0.1
- Numpy
最终该项目缺少文件(大概),没有运行成功,但是环境搭建好了,故记录一下。
colab使用和环境搭建
使用colab引入GitHub代码
挂载谷歌云盘
import os
os.chdir("/content/drive/My Drive")
获取GitHub代码
!git clone https://github.com/tuxchow/ECM-tf.git
进入项目文件夹
cd ECM-tf/
------------
/content/drive/My Drive/ECM-tf
查看目录
!ls
-------------
apply.py emo_embedding test_medium.py train.py
data_dict.py internal_mem test.py train_test_split.py
data.py model train_medium.py
ECM README.md train_mini.py
更改python版本
因为colab目前默认python版本为3.7,故要更改python版本为3.5
先下载python3.5
!apt-get install python3.5
卸载python3.7下的pip以免之后使用pip装包到3.7环境下
!python -m pip uninstall pip
切换环境为3.5
!update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.5 2
!update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.7 1
!python --version
--------------------
update-alternatives: renaming python3 link from /usr/bin/python3 to /usr/local/bin/python3
update-alternatives: using /usr/bin/python3.5 to provide /usr/local/bin/python3 (python3) in auto mode
Python 3.5.10
给python3.5安装pip
!apt-get install python3-pip
安装Numpy
升级(不升级安装不了Numpy)
!python3.5 -m pip install --upgrade pip
安装Numpy
!python3.5 -m pip install Numpy
安装tensorflow1.01
因为项目要求是tensorflow1.01
所以cuda存在匹配问题,需要卸载默认的cuda安装上cuda8.0
!apt-get remove cuda
!apt-get autoremove cuda
!apt-get purge cuda
!apt-key del /var/cuda-repo-9-2-local/*.pub
!rm -rf /var/cuda-repo-8-0-local-ga2/
安装cuda8.0
!sudo wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb
!sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb
!sudo apt-get update
!sudo apt-get -y install cuda-8-0
查看现在cuda版本
!nvcc --version
--------------------
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61
安装tensorflow1.0.1
!python3.5 -m pip install tensorflow==1.0.1
运行项目
!python3.5 test.py -m ECM
运行报错
FileNotFoundError: [Errno 2] No such file or directory: 'data/data_test.pkl'
应该是缺少文件
参考文章
protobuf requires Python ‘>=3.7‘ but the running Python is 3.6.5的解决方法
Google Colab Using GPU with Tensorflow version 1.0.0
标签:GitHub,代码,py,python3.5,cuda,colab,pip,local,python3 From: https://www.cnblogs.com/ryukirin/p/16640736.html