双系统下ubuntu20.04安装caffe(个人尝试)+踩坑记录

本文详细描述了在Ubuntu22.04环境下安装CaffeGPU版本时遇到的编译问题,包括OpenCV版本检查、路径配置、CUDNN和Protobuf依赖错误,以及解决这些问题的方法。还涉及了Python模块导入错误和系统设置调整等内容。
摘要由CSDN通过智能技术生成

主要参考的安装教程

ubuntu安装caffe完整版(GPU)_ubantu22.04安装caffe-CSDN博客

ubuntu20.04安装12.2版本的cuda_cuda12.2-CSDN博客

1.检查版本

(1)检查opencv版本 bash

pkg-config opencv --modversion

(2)在python环境中输出版本

import sys
print(sys.version)

(3)Ubuntu版本

lsb_release -a

2.bash

(1)删除文件夹

sudo rm -r 文件夹路径
sudo rm 文件路径

(2)复制文件夹

cp -r /path/to/source_folder /path/to/destination_location

(3)查看cuDNN版本

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

(4)查看protobuf版本

protoc --version

(5)添加环境变量

vim ~/.bashrc
source ~/.bashrc

(6)查找某个文件

find / -name "filename"

(7)查看内存大小

free -h

(8)Linux Ubuntu修改密码

passwd

(9)更改文件夹名称

mv oldfolderName newfolderName

3.报错

(1)安装caffe编译不通过

make all 报错1

opencv2/core/core.hpp: No such file or directory

因为我按照网上的多个教程安装,之间存在差异,文件配置的路径是不一致的

opencv4包含opencv2,下边图片是我的路径 /usr/local/include/opencv4

sudo ln -s /usr/include/opencv4/opencv2 /usr/include/

 make all 报错2

CXX src/caffe/util/io.cpp
src/caffe/util/io.cpp: In function ‘bool caffe::ReadProtoFromBinaryFile(const char*, google::protobuf::Message*)’:
src/caffe/util/io.cpp:57:34: warning: ‘void google::protobuf::io::CodedInputStream::SetTotalBytesLimit(int, int)’ is deprecated: Please use the single parameter version of SetTotalBytesLimit(). The second parameter is ignored. [-Wdeprecated-declarations]
   57 |   coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/caffe/util/io.cpp:2:
/usr/include/google/protobuf/io/coded_stream.h:397:8: note: declared here
  397 |   void SetTotalBytesLimit(int total_bytes_limit, int) {
      |        ^~~~~~~~~~~~~~~~~~
src/caffe/util/io.cpp: In function ‘cv::Mat caffe::ReadImageToCVMat(const string&, int, int, bool)’:
src/caffe/util/io.cpp:76:34: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
   76 |   int cv_read_flag = (is_color ? CV_LOAD_IMAGE_COLOR :
      |                                  ^~~~~~~~~~~~~~~~~~~
src/caffe/util/io.cpp:77:5: error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
   77 |     CV_LOAD_IMAGE_GRAYSCALE);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
src/caffe/util/io.cpp: In function ‘cv::Mat caffe::DecodeDatumToCVMat(const caffe::Datum&, bool)’:
src/caffe/util/io.cpp:182:34: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
  182 |   int cv_read_flag = (is_color ? CV_LOAD_IMAGE_COLOR :
      |                                  ^~~~~~~~~~~~~~~~~~~
src/caffe/util/io.cpp:183:5: error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
  183 |     CV_LOAD_IMAGE_GRAYSCALE);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:592: .build_release/src/caffe/util/io.o] Error 1

解决:

参考链接:链接里有的链接失效了,又找了其他连接。配合参考src/caffe/util/io.cpp: In function ‘bool caffe::ReadProtoFromBinaryFile(const char*, google::protobu_src/caffe/util/io.cpp:77:5: error: ‘cv_load_image_-CSDN博客

protobuf 版本问题 - 知乎
 

make all 报错3

LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lcudnn: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:584: .build_release/lib/libcaffe.so.1.0.0] Error 1

查找libcudnn.so

find / -name libcudnn.so*

/home/liujx/Downloads/cudnn-10.1-linux-x64-v7.6.5.32/cuda/lib64/libcudnn.so

添加这个路径到Makefile.config 的LIBRARY_DIRS

解决:

错误-解决/usr/bin/ld: cannot find -lxxx 问题_/usr/bin/ld: 找不到 -lgcbase_gcc421_v3_0 /usr/bin/ld:-CSDN博客

make all 报错4

collect2: error: ld returned 1 exit status
make: *** [Makefile:638: .build_release/tools/upgrade_net_proto_text.bin] Error 1
collect2: error: ld returned 1 exit status
make: *** [Makefile:638: .build_release/tools/extract_features.bin] Error 1

protobuf重装

make test 报错1

src/caffe/test/test_io.cpp: In function ‘bool caffe::ReadImageToDatumReference(const string&, int, int, int, bool, caffe::Datum*)’:
src/caffe/test/test_io.cpp:23:34: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
   23 |   int cv_read_flag = (is_color ? CV_LOAD_IMAGE_COLOR :
      |                                  ^~~~~~~~~~~~~~~~~~~
src/caffe/test/test_io.cpp:24:5: error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
   24 |     CV_LOAD_IMAGE_GRAYSCALE);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:598: .build_release/src/caffe/test/test_io.o] Error 1
make: *** Waiting for unfinished jobs....

解决:SLAM十四讲,第七章程序ch7报错, error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope-CSDN博客

make runtest 报错1

.build_release/tools/caffe
.build_release/tools/caffe: error while loading shared libraries: libcudnn.so.7: cannot open shared object file: No such file or directory
make: *** [Makefile:548: runtest] Error 127

解决:error while loading shared libraries: libcudnn.so.7: cannot open shared object file: No such file or_oserror: libcudnn.so.7: cannot open shared object -CSDN博客

make runtest 报错2

.build_release/test/test_all.testbin 0 --gtest_shuffle
Cuda number of devices: 1
Setting to use device 0
Current device id: 0
Current device name: NVIDIA GeForce RTX 4050 Laptop GPU

F0201 14:56:04.722941  8000 pooling_layer.cu:212] Check failed: error == cudaSuccess (222 vs. 0)  the provided PTX was compiled with an unsupported toolchain.

解决方案1:https://www.cnblogs.com/sddai/p/10209502.html

我在使用这个这个方法时,出现了更多的RUN OK,运行时间变长,但是最后还是报同样的错

解决方案2:官网说是

This indicates that the provided PTX was compiled with an unsupported toolchain. The most common reason for this, is the PTX was generated by a compiler newer than what is supported by the CUDA driver and PTX JIT compiler.

(2)import caffe 错误1

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/liujx/Downloads/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/home/liujx/Downloads/caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ModuleNotFoundError: No module named 'caffe._caffe'

解决:ubuntu18——ModuleNotFoundError: No module named 'caffe._caffe'-CSDN博客

4.资源地址

(1)cuda各版本

CUDA Toolkit Archive | NVIDIA Developer

其他

(1)ubuntu截屏

键盘 PRT SC 按键

(2)ubuntu切换输入法

win+space

(3)Linux Ubuntu外接显示屏调整顺序

Settings --> displays

参考链接:Ubuntu18.04 调整双屏顺序_如何修改显示屏编号12 ubuntu-CSDN博客

(4)Linux Ubuntu 息屏设置

Settings-->Power-->Power Saving Options-->Screen Blank

(5)双系统时间不一致问题

timedatectl set-local-rtc 1

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

修神成仙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值