win10在Anaconda3下面安装caffe框架(CPU)Python2.7从入门到放弃

本文详细记录了在Windows 10上,使用Anaconda3环境安装CPU版Caffe的过程,包括安装步骤、遇到的问题及解决方案。通过修改环境变量、安装依赖库,最终成功在Python环境中导入Caffe并进行测试。尽管在VS2013下编译遇到困难,但通过调整配置和安装protobuf,最终实现了Caffe的运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最新更新

https://blog.youkuaiyun.com/baidu_40691432/article/details/121426736

电脑系统重装,在2021年的11月再次在win10系统上安装caffe进行对比实验代码运行。

注意事项:

  1. CPU-Only版本安装较为简单。不需要考虑cuda和cudnn相关版本适配等问题。但计算速度要比GPU版本的慢。
  2. python2.7配套visual studio2013进行安装,anaconda新建环境内部安装cmake。新安装环境下的各版本信息:其中,caffe版本在这里不显示。
  3. caffe运行的文件夹。其中,caffe是github上下载的文件夹,切到window版本。
    https://github.com/BVLC/caffe/tree/windows

    build_win.cmd代码如下,供参考。ninja安装的版本有点问题,withNinja = 0, CPU_only=1,vs=12 

    @echo off
    @setlocal EnableDelayedExpansion
    
    :: Default values
    if DEFINED APPVEYOR (
        echo Setting Appveyor defaults
        if NOT DEFINED MSVC_VERSION set MSVC_VERSION=12
        if NOT DEFINED WITH_NINJA set WITH_NINJA=0
        if NOT DEFINED CPU_ONLY set CPU_ONLY=1
        if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
        if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
        if NOT DEFINED USE_NCCL set USE_NCCL=0
        if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
        if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
        if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
        if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
        if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=0
        if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
        if NOT DEFINED RUN_TESTS set RUN_TESTS=1
        if NOT DEFINED RUN_LINT set RUN_LINT=1
        if NOT DEFINED RUN_INSTALL set RUN_INSTALL=1
    
        :: Set python 2.7 with conda as the default python
        if !PYTHON_VERSION! EQU 2 (
            set CONDA_ROOT=C:\Miniconda-x64
        )
        :: Set python 3.5 with conda as the default python
        if !PYTHON_VERSION! EQU 3 (
            set CONDA_ROOT=C:\Miniconda35-x64
        )
        set PATH=!CONDA_ROOT!;!CONDA_ROOT!\Scripts;!CONDA_ROOT!\Library\bin;!PATH!
    
        :: Check that we have the right python version
        !PYTHON_EXE! --version
        :: Add the required channels
        conda config --add channels conda-forge
        conda config --add channels willyd
        :: Update conda
        conda update conda -y
        :: Download other required packages
        conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml pydotplus graphviz
    
        if ERRORLEVEL 1  (
          echo ERROR: Conda update or install failed
          exit /b 1
        )
    
        :: Install cuda and disable tests if needed
        if !WITH_CUDA! == 1 (
            call %~dp0\appveyor\appveyor_install_cuda.cmd
            set CPU_ONLY=0
            set RUN_TESTS=0
            set USE_NCCL=1
        ) else (
            set CPU_ONLY=1
        )
    
        :: Disable the tests in debug config
        if "%CMAKE_CONFIG%" == "Debug" (
            echo Disabling tests on appveyor with config == %CMAKE_CONFIG%
            set RUN_TESTS=0
        )
    
        :: Disable linting with python 3 until we find why the script fails
        if !PYTHON_VERSION! EQU 3 (
            set RUN_LINT=0
        )
    
    ) else (
        :: Change the settings here to match your setup
        :: Change MSVC_VERSION to 12 to use VS 2013
        if NOT DEFINED MSVC_VERSION set MSVC_VERSION=12
        :: Change to 1 to use Ninja generator (builds much faster)
        if NOT DEFINED WITH_NINJA set WITH_NINJA=0
        :: Change to 1 to build caffe without CUDA support
        if NOT DEFINED CPU_ONLY set CPU_ONLY=1
        :: Change to generate CUDA code for one of the following GPU architectures
        :: [Fermi  Kepler  Maxwell  Pascal  All]
        if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
        :: Change to Debug to build Debug. This is only relevant for the Ninja generator the Visual Studio generator will generate both Debug and Release configs
        if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
        :: Set to 1 to use NCCL
        if NOT DEFINED USE_NCCL set USE_NCCL=0
        :: Change to 1 to build a caffe.dll
        if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
        :: Change to 3 if using python 3.5 (only 2.7 and 3.5 are supported)
        if NOT DEFINED PYTHON_VERSION 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值