C3D(pytorch)实现代码链接
C3D代码链接
2.C3D代码复现过程我认为这位博主对于C3D复现过程的描述是非常好的。
https://blog.csdn.net/yuanhaopeng123/article/details/113459528
我就是跟着博主将代码运行起来的,不过对于我的服务器内部cuda为11.1所以会在训练的步骤出错。
错误如下:
pytorch runtime error: CUDNN_STATUS_MAPPING_ERROR
接下来我将讲一下如何在Linux系统Ubuntu 20.04 ,cuda=11.1。实现C3D代码训练环境。
一、在Anaconda(我是3版本)创建一个新的环境
python3.6的环境。这个环境的名字我们起作“pytorch36"
conda create --name pytorch36 python=3.6
跟着步骤点击y确认安装。
二、激活此环境
conda activate pytorch36
三、安装pytorch
因为在pytorch官网上并没有cuda=11.1版本的pytorch下载方式,但是我们却需要与我们服务器的版本吻合。所以我们使用清华源地址去获取所需要的pytorch。
添加清华源地址
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes
为了保险起见,建议同时添加第三方的conda源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
四、安装pytorch
conda install pytorch torchvision torchaudio cudatoolkit=11.1
cuda版本为11.1.
根据查找我们可知道cudnn的对应版本为8.2.1,所以输入此命令安装cudnn.
conda install cudnn=8.2.1
如果你不知道你的cudnn版本,可直接输入如下命令,系统会给你安装匹配的版本。
conda install cudnn
这就安装成功pytorch啦,接下来进行验证
python # 进入python 环境 import torch # 导入安装的pytorch包 torch.cuda.is_available() # 检查cuda是否可以使用
没有报错,最后输出True代表成功啦!!!
五、接下来安装C3D代码运行所需的模块
conda install opencv conda install tqdm conda install scikit-learn conda install tensorboardX conda install torchvision conda install matplotlib conda install dominate
接下来运行代码,如果出现以下错误:
TypeError: __new__() got an unexpected keyword argument 'serialized_options'
出现该问题,很有可能是,终端上的 protoc 版本 与python库内的protobuf版本不一样。
解:安装对应版本的库即可!比如我的执行下列命令
pip install -U protobuf
然后继续运行就好啦。



