Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

python-2.7 - Linux CentOS 7上的CMake,如何强制系统使用cmake3?(CMake on Linux CentOS 7, how to force the system to use cmake3?)

I tried to install PyTorch on my Linux CentOS 7.3.

(我试图在Linux CentOS 7.3上安装PyTorch 。)

I downloaded its package, ran this command and got this error:

(我下载了它的软件包,运行了这个命令,并得到了这个错误:)

sudo python setup.py install

running install
running build_deps
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.0 or higher is required.  You are running version 2.8.12.2


-- Configuring incomplete, errors occurred!

So I tried to install CMake 3 by using the command

(所以我尝试使用以下命令安装CMake 3)

sudo yum -y install cmake3

The installation went alright, but the system still uses cmake2.8 as default.

(安装一切正常,但系统仍使用cmake2.8作为默认设置。)

If I type the yum info comnmand, I get this:

(如果输入yum info命令,则会得到以下信息:)

sudo yum info cmake

Installed Packages
Name        : cmake
Arch        : x86_64
Version     : 2.8.12.2
Release     : 2.el7
Size        : 27 M
Repo        : installed
From repo   : base
Summary     : Cross-platform make system
URL         : http://www.cmake.org
License     : BSD and MIT and zlib
Description : CMake is used to control the software compilation process using simple
            : platform and compiler independent configuration files. CMake generates
            : native makefiles and workspaces that can be used in the compiler
            : environment of your choice. CMake is quite sophisticated: it is possible
            : to support complex environments requiring system configuration, preprocessor
            : generation, code generation, and template instantiation.

So, the problem is clear: the system still sees cmake2.8 as default, and therefore Python does not use cmake3 for its PyTorch installation.

(因此,问题很明显: 系统仍然将cmake2.8视为默认设置,因此Python并未在其PyTorch安装中使用cmake3。)

How can I solve this problem?

(我怎么解决这个问题?)

Thanks

(谢谢)

  ask by DavideChicco.it translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Once you have both the cmake and the cmake3 package installed on your machine, you can use update-alternatives to switch between both packages.

(在计算机上同时安装了cmakecmake3软件包之后,就可以使用update-alternatives在这两个软件包之间切换。)

Use the alternatives command to register both installations:

(使用alternatives命令注册两个安装:)

$ sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 
--slave /usr/local/bin/ctest ctest /usr/bin/ctest 
--slave /usr/local/bin/cpack cpack /usr/bin/cpack 
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake 
--family cmake

$ sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 
--family cmake

After these two commands, cmake3 will be invoked by default, when you enter cmake from a bash prompt or start a bash script.

(在这两个命令之后,当您从bash提示符下输入cmake或启动bash脚本时,默认情况下将调用cmake3 。)

The commands also take care of registering a few additional slave commands like ctest which need to be switched along with cmake .

(这些命令还负责注册一些其他的从命令,例如ctest ,这些命令需要与cmake一起切换。)

If you need to switch back to cmake 2.8 as the default, run the following command:

(如果您需要切换回默认的cmake 2.8,请运行以下命令:)

$ sudo alternatives --config cmake

There are 2 programs which provide 'cmake'.

  Selection    Command
-----------------------------------------------
   1           cmake (/usr/bin/cmake)
*+ 2           cmake (/usr/bin/cmake3)

Enter to keep the current selection[+], or type selection number: 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...