悠然居 發表於 2024-6-21 11:35:00

fedora环境配置

<h2 id="基础配置">基础配置</h2>
<h3 id="1-更换镜像源加速下载">1. 更换镜像源加速下载</h3>
<p>加速dnf<br>
<code>/etc/dnf/dnf.conf</code></p>
<pre><code class="language-bash">fastestmirror=True
max_parallel_downloads=32
defaultyes=True
keepcache=True
</code></pre>
<p>更换清华源</p>
<pre><code class="language-bash">sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.ustc.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-updates.repo

sudo dnf update
</code></pre>
<p>启动rpm-fusion源</p>
<pre><code class="language-bash">sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
</code></pre>
<p>fedora flatpak</p>
<pre><code class="language-bash">flatpak remote-delete fedora
sudo flatpak remote-modify flathub --url=https://mirror.sjtu.edu.cn/flathub
</code></pre>
<h3 id="2-development-tools">2. development tools</h3>
<pre><code class="language-bash">sudo dnf groupinstall "Development Tools"
sudo dnf install -y gcc gcc-c++ git cmake ninja-build zlib-devel
</code></pre>
<p>安装并配置Rust</p>
<pre><code class="language-bash">export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
export PATH="$HOME/.cargo/bin:$PATH"
curl https://sh.rustup.rs -sSf | sh

echo 'PATH="$HOME/.cargo/bin:$PATH"' &gt;&gt; ~/.zshrc
</code></pre>
<p><code>$HOME/.cargo/config.toml</code></p>
<pre><code class="language-toml">
replace-with = 'aliyun'

registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"
</code></pre>
<p><code>.zshrc</code></p>
<pre><code class="language-bash">export PATH="$HOME/.cargo/bin:$PATH"
</code></pre>
<h3 id="3-ssh">3. ssh</h3>
<pre><code class="language-bash">sudo sed -i -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' \
            -e 's/#Port 22/Port 22/' \
            -e 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' \
            -e 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
systemctl daemon-reload
</code></pre>
<h3 id="4-text-editor">4. text editor</h3>
<pre><code class="language-bash">sudo dnf install vim neovim
</code></pre>
<h3 id="5-tampermonkey-firefox">5. Tampermonkey-firefox</h3>
<p>TamperMonkey<br>
CSDN</p>
<h3 id="6-proxy-tools">6. proxy-tools</h3>
<pre><code class="language-bash">wget https://files.catbox.moe/mreuef.gz
tar -xzf mreuef.tar.gz
</code></pre>
<h2 id="可选配置">可选配置</h2>
<h3 id="ibus">ibus</h3>
<pre><code class="language-bash"># 似乎不管是ibus还是fcitx在fedora中最近总是失效
# 就像是:ModuleNotFoundError: No module named 'gi'
# 解决办法如下:
sudo dnf install gcc gobject-introspection-devel cairo-gobject-devel pkg-config python3-devel gtk4
pip3 install pycairo
pip3 install PyGObject
</code></pre>
<h3 id="fcitx5">fcitx5</h3>
<pre><code class="language-bash">sudo dnf install fcitx5-chinese-addons fcitx5-autostart

# Gnome美化
# https://extensions.gnome.org/extension/261/kimpanel/
</code></pre>
<hr>
<h3 id="todesk">todesk</h3>
<pre><code class="language-bash">cd Downloads
wget https://dl.todesk.com/linux/todesk-v4.7.2.0-x86_64.rpm # direct-link
sudo yum install libappindicator-gtk3
sudo rpm -Uvh todesk-v4.7.2.0-x86_64.rpm

# 记得将gnome来关闭挂起
</code></pre>
<h3 id="zerotier">zerotier</h3>
<pre><code class="language-bash">curl -s https://install.zerotier.com | sudo bash
</code></pre>
<hr>
<h3 id="vscode">VSCode</h3>
<pre><code class="language-bash">sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo &gt; /dev/null

dnf check-update
sudo dnf install code # or code-insiders
</code></pre>
<h3 id="jetbrains">jetbrains</h3>
<pre><code class="language-bash">wget https://download.jetbrains.com/toolbox/jetbrains-toolbox-2.3.2.31487.tar.gz
</code></pre>
<h3 id="astronvim">astronvim</h3>
<pre><code class="language-bash">git clone https://github.com/Mieluoxxx/astronvim_config ~/.config/nvim
nvim --headless -c 'quitall'
</code></pre>
<hr>
<h3 id="oh-my-zsh">oh-my-zsh</h3>
<pre><code class="language-bash">sudo dnf install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
ZSH_CUSTOM="${ZSH:-$HOME/.oh-my-zsh}/custom"
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions &amp;&amp; \
git clone https://github.com/zsh-users/zsh-completions $ZSH_CUSTOM/plugins/zsh-completions &amp;&amp; \
git clone https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

sed -i '/^plugins=(/ s/)$/ zsh-autosuggestions zsh-completions zsh-syntax-highlighting)/' ~/.zshrc
source ~/.zshrc
</code></pre>
<h3 id="zoxide">zoxide</h3>
<pre><code class="language-bash">cargo install zoxide
sudo dnf install fzf

echo 'eval "$(zoxide init zsh)"' &gt;&gt; ~/.zshrc
source ~/.zshrc
</code></pre>
<hr>
<h3 id="miniconda3">miniconda3</h3>
<pre><code class="language-bash">mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh

./miniconda3/bin/conda init zsh
source ~/.zshrc
</code></pre>
<h3 id="fedora-nvidia-深度学习环境搭建">Fedora NVIDIA 深度学习环境搭建</h3>
<h4 id="section-1">section 1</h4>
<pre><code class="language-bash">sudo dnf update
sudo dnf -y install kernel-devel
sudo dnf -y install gcc

# 检查版本,保持一致
uname -r
rpm -qa | grep kernel
</code></pre>
<h4 id="section-2">section 2</h4>
<pre><code class="language-bash"># 1. check nouveau
lsmod | grep nouveau

# 2. check gpu
lspci | grep VGA

# 3. blacklist
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
#options nouveau modeset=0

#安装用于处理ELF(可执行和链接格式)文件的开发工具库:elfutils-libelf-devel
sudo dnf install elfutils-libelf-devel

# 4. 重新初始化RAM磁盘,确保系统包含了最新的驱动程序和配置
sudo dracut -f

# 下载对应版本的NVIDIA显卡驱动
aria2c -s 4 -x 4 -j 10 https://us.download.nvidia.com/XFree86/Linux-x86_64/555.52.04/NVIDIA-Linux-x86_64-555.52.04.run
chmod a+x NVIDIA-Linux-x86_64-555.52.04.run

# 注销用户
# ctrl + alt + f2 进入 tty
sudo ./NVIDIA-Linux-x86_64-555.52.04.run

reboot
</code></pre>
<p><img src="https://img2023.cnblogs.com/blog/3390168/202406/3390168-20240621205126293-1809005274.png" alt="img" loading="lazy"></p>
<h4 id="section-3">section 3</h4>
<pre><code class="language-bash"># cuda程序
aria2c -s 4 -x 4 -j 10 https://developer.download.nvidia.com/compute/cuda/12.5.0/local_installers/cuda-repo-fedora39-12-5-local-12.5.0_555.42.02-1.x86_64.rpm
sudo rpm -i cuda-repo-fedora39-12-5-local-12.5.0_555.42.02-1.x86_64.rpm
sudo dnf clean all
sudo dnf -y install cuda-toolkit-12-5

echo 'PATH="/usr/local/cuda-12.5/bin:$PATH"' &gt;&gt; ~/.zshrc
echo 'LD_LIBRARY_PATH="/usr/local/cuda-12.5/lib64:$LD_LIBRARY_PATH"' &gt;&gt; ~/.zshrc
source ~/.zshrc

# cuda驱动
sudo dnf -y module install nvidia-driver:latest-dkms


# cudnn
aria2c -s 4 -x 4 -j 10 https://developer.download.nvidia.com/compute/cudnn/9.2.0/local_installers/cudnn-local-repo-rhel9-9.2.0-1.0-1.x86_64.rpm
sudo rpm -i cudnn-local-repo-rhel9-9.2.0-1.0-1.x86_64.rpm
sudo dnf clean all
sudo dnf -y install cudnn

sudo dnf -y install cudnn-cuda-12
</code></pre>
<hr>
<h3 id="启用-gtk4-的-vulkan-后端">启用 GTK4 的 Vulkan 后端</h3>
<pre><code class="language-bash">sudo vim /etc/environment

GSK_RENDERER=vulkan
</code></pre>
<h3 id="fedora测试通道">Fedora测试通道</h3>
<pre><code class="language-bash">sudo dnf update --enablerepo=updates-testing --refresh
</code></pre><br><br>
来源:https://www.cnblogs.com/moguw/p/18258504
頁: [1]
查看完整版本: fedora环境配置