1. Ubuntu 安装及问题处理
2. NVIDIA 驱动安装
- 步骤:
- 添加 NVIDIA 驱动程序 PPA:
sudo add-apt-repository ppa:graphics-drivers/ppa
- 更新软件包列表:
- 安装 NVIDIA 驱动程序:
sudo apt-get install nvidia-driver-xxx
(将 xxx 替换为具体版本号)
- 重启系统:
- 测试安装:
- 注意:驱动程序的安装和配置可能因不同显卡型号和 Ubuntu 版本而有所不同。
3. Jupyter GPU Docker 安装
- 命令:
docker run --gpus all nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04 nvidia-smi
docker run --restart always --gpus all -d -it -p 8848:8888 -v $(pwd)/jupyter-gpu:/home/jovyan/work -e GRANT_SUDO=yes -e JUPYTER_ENABLE_LAB=yes --user root cschranz/gpu-jupyter:v1.5_cuda-11.6_ubuntu-20.04
4. 结果检查
- 检查 GPU 可用性:
watch -n 2 nvidia-smi
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
- TensorFlow 和 PyTorch 检查:
import tensorflow as tf
tf.config.list_physical_devices('GPU')
tf.sysconfig.get_build_info()
import torch
torch.cuda.is_available()
torch.cuda.device_count()
torch.cuda.get_device_name(0)
5. Docker 更改安装位置
- 步骤:
- 停止 Docker 服务:
sudo systemctl stop docker
- 备份 Docker 数据:
sudo tar -czvf docker-backup.tar.gz /var/lib/docker
- 移动 Docker 数据目录:
sudo rsync -axP /var/lib/docker /home/kuhung/docker-data/
sudo mv /var/lib/docker /var/lib/docker.old
sudo ln -s /home/kuhung/docker-data/docker /var/lib/docker
- 启动 Docker 服务:
sudo systemctl start docker
- 验证新位置:
docker info | grep 'Docker Root Dir'
6. 一键安装
- 安装命令:
sudo apt install -y openssh-server
- 其他软件:Anaconda、CUDA、Docker
7. 电源管理
- 安装与使用:
sudo apt install python-pip stress
pip install s-tui
s-tui
8. 挂载 Windows 分区
- 步骤:
- 确认 Windows 分区:
- 创建挂载目录:
sudo mkdir /media/windows
- 挂载 Windows 分区:
sudo mount -t ntfs /dev/sdaX /media/windows
- 卸载分区:
sudo umount /media/windows
- 自动挂载:
sudo nano /etc/fstab
/dev/nvme0n1p6 /home/kuhung/data_n1p6 ntfs defaults 0 0
/dev/nvme0n1p8 /home/kuhung/project_n1p8 ntfs defaults 0 0
9. 查找大文件
- 命令:
find /home -type f -exec du -h {} + | sort -hr | head -20
10. 远程连接
- 安装与配置:
sudo apt update
sudo apt install xrdp
sudo systemctl enable xrdp
sudo systemctl start xrdp
sudo ufw allow 3389/tcp
11. 文件共享
- 在 Ubuntu 上安装 Samba:
sudo apt update
sudo apt install samba
- 配置 Samba:
sudo nano /etc/samba/smb.conf
12. Windows 安装及问题处理
- 安装内存
- 磁盘写保护:
diskpart
list disk
select disk 1
create partition primary
format fs=ntfs quick
13. 路由器刷机
14. 树莓派
- 重启后自动执行命令:
# 添加到 exit 0之前
sudo vi /etc/rc.local
15. OpenWrt
- 磁盘挂载:
echo "/dev/sda1 /mnt/sda1 exfat defaults 0 0" >> /etc/fstab
16. Docker
- 安装图形监控:
docker run -p 9000:9000 -p 8000:8000 --name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /mydata/portainer/data:/data \
-d portainer/portainer
17. Git 相关
- 重命名分支:
- 切换到其他分支:
- 重命名分支:
git branch -m <旧分支名> <新分支名>
- 推送更改到远程:
git push origin :<旧分支名>
git push origin <新分支名>
- 删除分支:
- 删除已合并的分支:
git branch -d <branch_name>
- 强制删除未合并的分支:
git branch -D <branch_name>
18. 驱动安装
- NVIDIA 驱动安装:
sudo apt-get update
sudo apt-get install nvidia-driver
sudo apt-get install -y nvidia-container-toolkit
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
19. Conda
- 创建环境并安装包:
conda create -n automl python=3.10
pip install torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install autogluon
- 创建临时环境:
conda create -n temp python=3.9
pip install tensorflow==2.9.0
pip install autokeras==1.0.19
conda remove -n temp --all
Author:
谷粒
Link:
本文采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可