有关CentOS的一些Tips

Posted ViviranZ

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了有关CentOS的一些Tips相关的知识,希望对你有一定的参考价值。

2021/9/11

师兄帮我在工作站电脑上安装了Linux系统弄了个单独账号!师兄yyds!接下来就是配置过程了~

思路:anacoda-python3.7-pip/pytorch/cocoapi。。。。

其它:中文输入法、文件传输

1.中文输入法:

感谢师兄帮忙安装啦!具体思路是这个

CentOS7.6中安装使用fcitx框架|CentOS安装输入法_智识帮的博客-CSDN博客内容目录一、为什么要使用fcitx?二、安装fcitx框架三、安装搜狗输入法一、为什么要使用fcitx?Gnome3桌面自带的输入法框架为ibus,而在使用ibus时会时不时出现卡顿无法输入的现象。搜狗和谷歌输入法等使用的是fcitx框架。而ibus会造成fcitx无法正常启动,所以我们需要先卸载ibus。注意:不可直接yum erase ibus,会...https://blog.csdn.net/mdykj33/article/details/99717016切换输入法是Win+空格,很方便!

2.sudoers:

然后我发现我用不了sudo,原来是我没有权限……看这个

qLinux给用户添加sudo权限 - henrylinux - 博客园q一、linux给用户添加sudo权限: 有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file. This incidenhttps://www.cnblogs.com/henrylinux/p/9746835.html其中发现我不太会用vim的命令,看了这个

如何在Vim/Vi中保存文件并退出编辑器 | myfreax

3.anacoda

首先查看一下Linux版本:

[zwr@MiWiFi-R3P-srv ~]$ cat /proc/version
Linux version 3.10.0-1160.42.2.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Sep 7 14:49:57 UTC 2021

然后按照这个:

Linux-Centos7下安装Anaconda(2019年新版) - 知乎

下载安装(我选择最新版了),但是环境变量设置那里不太一样,主要跟随这个:

centOS系统中将anaconda加入环境变量_sxt1001的博客-CSDN博客https://blog.csdn.net/sxt1001/article/details/80628005加入环境变量,总体来说就是 press a进入编辑模式,press Esc推出模式,之后【:q】保存,显示只读文件需要加【!】,但是还是不行,这时候看了这个

ubuntu文档保存出现的一些错误_无限大地NLP_空木的专栏-CSDN博客

然后出了问题和这个一样:


运行source /etc/profile 提示-bash: etc/profile: 没有那个文件或目录_Anakin Meng的博客-CSDN博客

然后【:q】退出,显示仍有信息未保存,不管它直接退出,然后vim重新进一遍,发现修改成功了。然后完成环境变量修改……

还不行!!!然后又找了一个……

【anaconda】激活环境失败-bash: activate:No such file/没有那个文件或目录_TomRen-CSDN博客

然后安装了jupyter~

linux 安装anaconda 和 jupyter_solimania的博客-CSDN博客

啊啊啊动起来了!!!

现在就需要双向推动。1.怎么从Windows本地和服务器Linux之间方便地互通文件?(以上图片是邮箱发送的) 2.按照代码的要求安装python、包等

2021/9/13

互传文件

首先是确认,apt-get用yum install代替

Centos7安装apt-get 在centos下用yum install xxx        不是使用apt-get_易的博客-CSDN博客

先看的这个博客:

Windows与Linux互传文件的几种方式_guotianqing的博客-CSDN博客_windows与linux文件互传

本地和服务器文件互传_wwqcherry的博客-CSDN博客_citrix和本地文件互传

然后发现文件夹的名字搜索不到,推测可能是因为中文显示的原因,因此看了

linux系统如何将系统中的文件名改为英文?_MZ21G的博客-CSDN博客

把文件夹都设置成了英文,之后发现我直接用Windows自带的远程桌面连接并没有弹出窗口,(Connection refused)于是尝试用Xshell+Xftp……

Free for Home/School - Xshell and Xftp Free Licensing

 安装成功了,Xshell还行,Xftp连不上……决定Github上传下载报平安……

https://jingyan.baidu.com/article/b87fe19eca972b1219356872.html

之后,从Github下载了CIL的代码,对着看……

安装python37

开始尝试安装python3.7

centos7 如何安装与使用 Anaconda - 云+社区 - 腾讯云

在利用conda activate进入py37的时候,发现有一个invalid shell,发现可能是之前安装了一半出现了问题,于是采用这个帖子介绍的方法,进入了python环境。

CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘._sdnuwjw的博客-CSDN博客

其实根本用不着进入环境,直接jupyter吧,进入方式:

然后需要保持这个终端处于开启状态,要不会影响

尝试着码了输出hello world和1+1,还可以,开始准备pytorch

 安装pytorch

首先查看系统CUDA信息

CentOS查看显卡及GPU相关信息,指定GPU、CPU运行_GlassySky的博客-CSDN博客_centos查看显卡

然后发现代码需要pytorch的版本是0.4.0,而工作站电脑自带的是11.4(查看方式如下:)

centos下通过conda安装pytorch和tensorflow - 1直在路上1 - 博客园

网上查了一下需要安装低版本的CUDA……

妈耶最终还是需要信息……

centos下通过conda安装pytorch和tensorflow - 1直在路上1 - 博客园

[zwr@MiWiFi-R3P-srv ~]$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[zwr@MiWiFi-R3P-srv ~]$ cat /proc/version
Linux version 3.10.0-1160.42.2.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Sep 7 14:49:57 UTC 2021
[zwr@MiWiFi-R3P-srv ~]$ lspci | grep -i nvidia
65:00.0 VGA compatible controller: NVIDIA Corporation Device 2204 (rev a1)
65:00.1 Audio device: NVIDIA Corporation Device 1aef (rev a1)
[zwr@MiWiFi-R3P-srv ~]$ nvidia-smi
Mon Sep 13 22:11:34 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.63.01    Driver Version: 470.63.01    CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:65:00.0  On |                  N/A |
|  0%   55C    P8    29W / 350W |    108MiB / 24265MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      2436      G   /usr/bin/X                         84MiB |
|    0   N/A  N/A      2597      G   /usr/bin/gnome-shell               16MiB |
|    0   N/A  N/A      3777      G   /usr/lib64/firefox/firefox          4MiB |
+-----------------------------------------------------------------------------+

然后跟着这个……

linux 命令行下安装特定版本的 cuda (踩坑记录) - _荒流 - 博客园

他专门讲驱动……

linux 命令行下适配 nvidia 驱动 - _荒流 - 博客园

但是没找到对应显卡的驱动,查询显卡驱动的网站如下:

PCI Devices

下载驱动的网址如下:

linux 命令行下安装特定版本的 cuda (踩坑记录) - _荒流 - 博客园

不行了明天搞

2021/9/14

凌晨问了一下大佬,说CUDA新版本和旧版本是兼容的,因此不需要重新装驱动,上午试了试

conda install pytorch=0.4.0 cuda90 -c pytorch

发现显示我的python版本过高(3.8),正好问了下熊哥,说在anaconda里再装一个低版本的python环境吧

于是采用这个代码

conda create -n py36 python=3.6

之后一路”y“下去就安装完了,但是在activate的时候出现了新的问题

[zwr@MiWiFi-R3P-srv ~]$ conda activate py36

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.


[zwr@MiWiFi-R3P-srv ~]$ conda init py36

ArgumentError: Invalid shells: 
  - py36

Currently available shells are:
  - bash
  - fish
  - powershell
  - tcsh
  - xonsh
  - zsh

[zwr@MiWiFi-R3P-srv ~]$ conda init
no change     /home/zwr/anaconda3/condabin/conda
no change     /home/zwr/anaconda3/bin/conda
no change     /home/zwr/anaconda3/bin/conda-env
no change     /home/zwr/anaconda3/bin/activate
no change     /home/zwr/anaconda3/bin/deactivate
no change     /home/zwr/anaconda3/etc/profile.d/conda.sh
no change     /home/zwr/anaconda3/etc/fish/conf.d/conda.fish
no change     /home/zwr/anaconda3/shell/condabin/Conda.psm1
no change     /home/zwr/anaconda3/shell/condabin/conda-hook.ps1
no change     /home/zwr/anaconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change     /home/zwr/anaconda3/etc/profile.d/conda.csh
modified      /home/zwr/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

然后熊哥远程指导让我查看信息

[zwr@MiWiFi-R3P-srv ~]$ ps -al
F S   UID    PID   PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S  1000   2413   2365  0  80   0 - 28320 do_wai tty1     00:00:00 startx
0 S  1000   2435   2413  0  80   0 -  3505 do_wai tty1     00:00:00 xinit
4 S     0   2436   2435  0  80   0 - 6364698 ep_pol tty1   00:00:53 X
0 S  1001  60092  58999  0  80   0 - 85241 ep_pol pts/0    00:00:10 jupyter-note
0 R  1001  90404  90296  0  80   0 - 38331 -      pts/1    00:00:00 ps

之后新建了一个bash(用来人机交互的页面)就可以成功activate拉

[zwr@MiWiFi-R3P-srv ~]$ bash
(base) [zwr@MiWiFi-R3P-srv ~]$ conda init bash
no change     /home/zwr/anaconda3/condabin/conda
no change     /home/zwr/anaconda3/bin/conda
no change     /home/zwr/anaconda3/bin/conda-env
no change     /home/zwr/anaconda3/bin/activate
no change     /home/zwr/anaconda3/bin/deactivate
no change     /home/zwr/anaconda3/etc/profile.d/conda.sh
no change     /home/zwr/anaconda3/etc/fish/conf.d/conda.fish
no change     /home/zwr/anaconda3/shell/condabin/Conda.psm1
no change     /home/zwr/anaconda3/shell/condabin/conda-hook.ps1
no change     /home/zwr/anaconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change     /home/zwr/anaconda3/etc/profile.d/conda.csh
no change     /home/zwr/.bashrc
No action taken.
(base) [zwr@MiWiFi-R3P-srv ~]$ conda activate py36

之后顺利安装了pytorch和torchvision、更新了numpy

(py36) [zwr@MiWiFi-R3P-srv ~]$ conda install pytorch=0.4.0 cuda90 -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/zwr/anaconda3/envs/py36

  added / updated specs:
    - cuda90
    - pytorch=0.4.0


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pytorch-0.4.0              |py36_cuda9.0.176_cudnn7.1.2_1       452.2 MB  pytorch
    ------------------------------------------------------------
                                           Total:       452.2 MB

The following NEW packages will be INSTALLED:

  blas               pkgs/main/linux-64::blas-1.0-openblas
  cffi               pkgs/main/linux-64::cffi-1.14.6-py36h400218f_0
  cuda90             pytorch/linux-64::cuda90-1.0-h6433d27_0
  cudatoolkit        pkgs/main/linux-64::cudatoolkit-9.2-0
  intel-openmp       pkgs/main/linux-64::intel-openmp-2021.3.0-h06a4308_3350
  libgfortran-ng     pkgs/main/linux-64::libgfortran-ng-7.5.0-ha8ba4b0_17
  libgfortran4       pkgs/main/linux-64::libgfortran4-7.5.0-ha8ba4b0_17
  libopenblas        pkgs/main/linux-64::libopenblas-0.3.13-h4367d64_0
  mkl                pkgs/main/linux-64::mkl-2021.3.0-h06a4308_520
  ninja              pkgs/main/linux-64::ninja-1.10.2-hff7bd54_1
  numpy              pkgs/r/linux-64::numpy-1.17.0-py36h99e49ec_0
  numpy-base         pkgs/r/linux-64::numpy-base-1.17.0-py36h2f8d375_0
  pycparser          pkgs/main/noarch::pycparser-2.20-py_2
  pytorch            pytorch/linux-64::pytorch-0.4.0-py36_cuda9.0.176_cudnn7.1.2_1


Proceed ([y]/n)? y


Downloading and Extracting Packages
pytorch-0.4.0        | 452.2 MB  | ######################################################################################################################################################################## | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(py36) [zwr@MiWiFi-R3P-srv ~]$ conda install torchvision=0.2.1
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/zwr/anaconda3/envs/py36

  added / updated specs:
    - torchvision=0.2.1


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    lz4-c-1.9.3                |       h295c915_1         185 KB
    olefile-0.46               |           py36_0          48 KB
    openjpeg-2.4.0             |       h3ad879b_0         331 KB
    pillow-8.3.1               |   py36h2c7a002_0         637 KB
    six-1.16.0                 |     pyhd3eb1b0_0          18 KB
    torchvision-0.2.1          |           py36_0          75 KB
    zstd-1.4.9                 |       haebb681_0         480 KB
    ------------------------------------------------------------
                                           Total:         1.7 MB

The following NEW packages will be INSTALLED:

  freetype           pkgs/main/linux-64::freetype-2.10.4-h5ab3b9f_0
  jpeg               pkgs/main/linux-64::jpeg-9b-h024ee3a_2
  lcms2              pkgs/main/linux-64::lcms2-2.12-h3be6417_0
  libpng             pkgs/main/linux-64::libpng-1.6.37-hbc83047_0
  libtiff            pkgs/main/linux-64::libtiff-4.2.0-h85742a9_0
  libwebp-base       pkgs/main/linux-64::libwebp-base-1.2.0-h27cfd23_0
  lz4-c              pkgs/main/linux-64::lz4-c-1.9.3-h295c915_1
  olefile            pkgs/main/linux-64::olefile-0.46-py36_0
  openjpeg           pkgs/main/linux-64::openjpeg-2.4.0-h3ad879b_0
  pillow             pkgs/main/linux-64::pillow-8.3.1-py36h2c7a002_0
  six                pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_0
  torchvision        pkgs/main/linux-64::torchvision-0.2.1-py36_0
  zstd               pkgs/main/linux-64::zstd-1.4.9-haebb681_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
olefile-0.46         | 48 KB     | ##################################### | 100% 
pillow-8.3.1         | 637 KB    | ##################################### | 100% 
torchvision-0.2.1    | 75 KB     | ##################################### | 100% 
lz4-c-1.9.3          | 185 KB    | ##################################### | 100% 
six-1.16.0           | 18 KB     | ##################################### | 100% 
openjpeg-2.4.0       | 331 KB    | ##################################### | 100% 
zstd-1.4.9           | 480 KB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(py36) [zwr@MiWiFi-R3P-srv ~]$ conda install numpy=1.18.1
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/zwr/anaconda3/envs/py36

  added / updated specs:
    - numpy=1.18.1


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    numpy-1.18.1               |   py36h94c655d_0           5 KB
    numpy-base-1.18.1          |   py36h2f8d375_1         4.1 MB
    ------------------------------------------------------------
                                           Total:         4.1 MB

The following packages will be UPDATED:

  numpy                 pkgs/r::numpy-1.17.0-py36h99e49ec_0 --> pkgs/main::numpy-1.18.1-py36h94c655d_0
  numpy-base         pkgs/r::numpy-base-1.17.0-py36h2f8d37~ --> pkgs/main::numpy-base-1.18.1-py36h2f8d375_1


Proceed ([y]/n)? y


Downloading and Extracting Packages
numpy-1.18.1         | 5 KB      | ##################################### | 100% 
numpy-base-1.18.1    | 4.1 MB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

结束拉!理论上接下来可以开始研究代码了嘿嘿嘿ie

以上是关于有关CentOS的一些Tips的主要内容,如果未能解决你的问题,请参考以下文章

ant design 使用中的一些tips

IOS开发-OC学习-常用功能代码片段整理

vbscript 各种自定义代码片段 - 有关详细信息,请参阅注释

CentOS Tips

ref:JAVA代码审计的一些Tips(附脚本)

Linux Tips