关于Ubuntu的使用
一、多版本java共存问题
我使用jdk8, jdk11, jdk17的共存问题
-
下载jdk包
-
关于jdk里没有jre,用以下命令创建
sudo bin/jlink --module-path jmods --add-modules java.desktop --output jre
-
解压到/usr/local/java/里
-
配置~/.bashrc添加变量设置别名
gedit ~/.bashrc
-
最后添加以下内容
# JAVA_ENV # jdk-8 export JAVA8_HOME=/usr/local/java/jdk-8 # jdk-11 export JAVA11_HOME=/usr/local/java/jdk-11 # jdk-17 export JAVA17_HOME=/usr/local/java/jdk-17 # JAVA_HOME export JAVA_HOME=${JAVA11_HOME} export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:${CLASSPATH} export PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:$PATH # java_alias alias jdk8='export JAVA_HOME=$JAVA8_HOME && export JRE_HOME=$JAVA_HOME/jre && export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH && export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' alias jdk11='export JAVA_HOME=$JAVA11_HOME && export JRE_HOME=$JAVA_HOME/jre && export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH && export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' alias jdk17='export JAVA_HOME=$JAVA17_HOME && export JRE_HOME=$JAVA_HOME/jre && export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH && export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH'
-
激活变量、别名
source ~/.bashrc
二、禁用nouveau、禁用蜂鸣器
-
编辑blacklist.conf
sudo gedit /etc/modprobe.d/blacklist.conf
-
在最后加上pcspkr、pcspkr
blacklist pcspkr blacklist nouveau
-
使文件生效
sudo update-initramfs -u
-
重启
三、关于安装英伟达显卡驱动
-
卸载原有的NVIDIA驱动
sudo apt-get remove –purge nvidia*
-
禁用nouveau
-
重启
-
检查nouveau是否成功禁用
lsmod | grep nouveau #没有输出禁用成功
-
安装NVIDIA驱动(CUDA Toolkit)
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget https://developer.download.nvidia.com/compute/cuda/11.5.0/local_installers/cuda-repo-ubuntu2004-11-5-local_11.5.0-495.29.05-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu2004-11-5-local_11.5.0-495.29.05-1_amd64.deb sudo apt-key add /var/cuda-repo-ubuntu2004-11-5-local/7fa2af80.pub sudo apt-get update sudo apt-get -y install cuda
-
编辑配置文件~/.bashrc添加变量
gedit ~/.bashrc # 在最后添加 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 export PATH=$PATH:/usr/local/cuda/bin export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
-
激活变量
source ~/.bashrc
-
验证
nvidia-smi # 安装成功输出显卡信息
cd /usr/local/cuda/samples/1_Utilities/deviceQuery sudo make ./deviceQuery # 安装成功输出 ./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking) Detected 1 CUDA Capable device(s) Device 0: "GeForce RTX 2070 with Max-Q Design" CUDA Driver Version / Runtime Version 11.0 / 11.0 CUDA Capability Major/Minor version number: 7.5 Total amount of global memory: 7982 MBytes (8370061312 bytes) (36) Multiprocessors, ( 64) CUDA Cores/MP: 2304 CUDA Cores GPU Max Clock rate: 1125 MHz (1.12 GHz) Memory Clock rate: 5501 Mhz Memory Bus Width: 256-bit L2 Cache Size: 4194304 bytes Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384) Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 49152 bytes Total number of registers available per block: 65536 Warp size: 32 Maximum number of threads per multiprocessor: 1024 Maximum number of threads per block: 1024 Max dimension size of a thread block (x,y,z): (1024, 1024, 64) Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535) Maximum memory pitch: 2147483647 bytes Texture alignment: 512 bytes Concurrent copy and kernel execution: Yes with 3 copy engine(s) Run time limit on kernels: Yes Integrated GPU sharing Host Memory: No Support host page-locked memory mapping: Yes Alignment requirement for Surfaces: Yes Device has ECC support: Disabled Device supports Unified Addressing (UVA): Yes Device supports Managed Memory: Yes Device supports Compute Preemption: Yes Supports Cooperative Kernel Launch: Yes Supports MultiDevice Co-op Kernel Launch: Yes Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0 Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) > deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.0, CUDA Runtime Version = 11.0, NumDevs = 1 Result = PASS
四、关于docker安装问题
-
安装
curl -fsSL get.docker.com -o get-docker.sh sh get-docker.sh
-
验证
docker ersion
-
启动服务
sudo systemctl start docker # 查看状态 sudo systemctl status docker
-
设置开机启动
sudo systemctl start docker
-
关于安装docker之后apt-get update报错:仓库 “https://download.docker.com/linux/ubuntu focal Release” 不再含有 Release
# 修改源 vim /etc/apt/sources.list.d/docker.list # 改成这个源地址 deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu bionic stable
五、关于桌面快捷方式模板
[Desktop Entry]
Encoding=UTF-8
Name=eclipse
Comment=Eclipse IDE
Exec=/usr/local/eclipse/eclipse #根据软件的具体执行路径修改
Icon=/usr/local/eclipse/icon.xpm #根据软件的具体执行路径修改
Terminal=false #软件打开时是否启动终端
StartupNotify=false
Type=Application
Categories=Application;Development;
六、禁用开机检测
# 修改fstab文件
sudo vim /etc/fstab
# 把最后一列的参数都改成0