WSL开发环境搭建(openSUSE-Tumbleweed篇)

启用wsl2功能,请参考kali那篇文章

关于高级配置,跟kali那相同

安装openSUSE-Tumbleweed

在windows终端输入

1
wsl --install -d openSUSE-Tumbleweed

启动并初始化

启动openSUSE后会有一个图形化配置界面,自行设置好用户名和密码等

更换软件源

1
2
3
4
5
sudo zypper mr -da
sudo zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/tumbleweed/repo/oss' USTC:OSS
sudo zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/tumbleweed/repo/non-oss' USTC:NON-OSS
sudo zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/update/tumbleweed' USTC:UPDATE
sudo zypper ref

更换终端(可选)

1
2
3
sudo zypper in fish bash-completion
chsh -s /usr/bin/fish
exit

安装解码器

1
2
3
4
sudo zypper ar -cfp 90 'https://mirrors.aliyun.com/packman/suse/openSUSE_Tumbleweed/' packman
sudo zypper refresh
sudo zypper dist-upgrade --from packman --allow-vendor-change
sudo zypper install --from packman ffmpeg gstreamer-plugins-{good,bad,ugly,libav} libavcodec-full vlc-codecs

启用Systemd

1
2
3
sudo zypper in -t pattern wsl_systemd
exit
sudo systemctl is-system-running

启用WSLg

1
2
3
4
5
sudo zypper in -t pattern wsl_gui
sudo zypper install Mesa-demo-x
glxgears
sudo zypper in firefox xorg-x11
firefox

安装中文字体

1
2
3
sudo zypper install noto-sans-sc-fonts wqy-zenhei-fonts adobe-sourcehansans-cn-fonts adobe-sourcehanserif-cn-fonts
sudo zypper install glibc-locale glibc-locale-base
sudo localectl set-locale LANG=zh_CN.UTF-8

安装CUDA

1
2
3
4
5
6
7
sudo zypper install kernel-source kernel-devel gcc make git
sudo zypper addrepo https://developer.download.nvidia.com/compute/cuda/repos/opensuse15/x86_64/cuda-opensuse15.repo
sudo zypper refresh
sudo zypper install cuda-toolkit-12-6
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
nvcc --version

若提示冲突软件包,选1卸载冲突的包

测试CUDA

1
2
3
4
git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples/Samples/1_Utilities/deviceQuery
make
./deviceQuery
1
2
3
4
5
6
7
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
~/miniconda3/bin/conda init bash fish
exit
conda install pytorch torchvision torchaudio cudatoolkit -c pytorch -c nvidia
conda config --set auto_activate_base false
python

进入交互式环境

1
2
3
4
5
6
import torch
print("PyTorch version:", torch.__version__)
print("CUDA available:", torch.cuda.is_available())
print("CUDA device count:", torch.cuda.device_count())
print("CUDA device name:", torch.cuda.get_device_name(0))
exit()
1
conda install --name base --all --revision 0

配置开发环境

跟kali基本相同

1
sudo zypper in gcc java-21-openjdk

安装桌面环境

1
2
3
4
5
6
7
8
9
sudo zypper in -t pattern xfce4
sudo zypper in busybox-net-tools
echo startxfce4 > ~/.xsession
chmod +x ~/.xsession
sudo zypper in xrdp xorgxrdp
sudo systemctl enable --now xrdp
ifconfig | grep -w "inet" | grep -v 127.0.0.1 | awk '{print $2}' | awk -F ':' '{print $2}'
sudo vim /etc/xrdp/xrdp.ini #请把端口改成9999等数字,只要不是3389
sudo systemctl restart xrdp

接下来即可使用windows的远程桌面连接

如果要使用Windows的软件VcXsrv,在终端执行export DISPLAY=localhost:0之后startxfce4即可进入桌面环境


WSL开发环境搭建(openSUSE-Tumbleweed篇)
https://rukkhadevata123.github.io/2024/09/20/opensuse-wsl/
作者
Dawn Chirps
发布于
2024年9月20日
许可协议