Setting up Ubuntu on the Razer Blade 15 (2021)
View the Project on GitHub EtienneMueller/razer-blade-data-science
Here is how i set up my LambdaLabs TensorBook/Razer Blade 15 (2022, RTX 3070 Ti) to work with Ubuntu 24.04.
The Intel WiFi AX210-module is only natively supported from kernel 5.10. Initially it was the easiest to just install the latest version, but as pointed out in the issues older versions (at least 20.04 LTS) also ship with that or a newer kernel version.
Create a bootable USB-Stick with Ubuntu
Important: If you want to use Ubuntu as the only OS, but still want to keep the original recovery partition containing Windows (partition 0) DO NOT remove the other partitions. The recovery tool will only install Windows 10 on partition 3 without checking or recreating any partitions. It took me way too long to find this out, but in case that happens to you, you would need to manually create partition 1 (EFI=100MB), partition 2 (MSR=128MB) and a primary partition 3 for the C-Drive, where Windows 10 will be installed.
If you want to keep the original Razer wallpapers, make sure to copy them before formatting Windows. You can find them located under: C:\Windows\Web\Wallpaper
For the single boot setup, boot from the USB stick and install it by formatting the biggest partition as ext4, set mount point to “/” and click install.
For using Ubuntu alongside Windows you can simply choose “Install Ubuntu alongside Windows Boot Manager” (e.g. like described here).
After the lid was closed, the notebook goes back to suspend after a couple of seconds and stays in that loop until a restart. It can be fixed fairly easy by adding GRUB_CMDLINE_LINUX_DEFAULT="quiet splash button.lid_init_state=open"
to the grub configuration, as is described in the next section.
When the laptop has been put in sleep by suspending it or closing the lid, the trackpad was turning into weird issues making it unusable without a reboot, this can now be fix with this workaround :
Create a new file: /etc/systemd/system/acpi-wake-andy.service
[Unit]
Description=ACPI Wake Service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo RP05 | sudo tee /proc/acpi/wakeup"
[Install]
WantedBy=multi-user.target
Enable this serviece
sudo systemctl start acpi-wake-andy.service
sudo systemctl enable acpi-wake-andy.service
sudo systemctl status acpi-wake-andy.service # check status
Create a new file: /etc/modprobe.d/nvidia-s2idle.conf
options nvidia NVreg_EnableS0ixPowerManagement=1
NVreg_S0ixPowerManagementVideoMemoryThreshold=10000
Check status cat /sys/power/mem_sleep
output
[s2idle] deep // You can test the trackpad after suspend and stop here
s2idle [deep] // You need to change something in the grub configuration
Only if the above command output is on : s2idle [deep]
) you need to edit : /etc/default/grub
Add mem_sleep_default=s2idle to GRUB_CMDLINE_LINUX_DEFAULT :
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=s2idle"
Run sudo update-grub
and then reboot, the trackpad should work normally after a suspend.
Depending on whether you want to show the grub bootloader at startup or not, you might want to increase the font size of the grub menu (especially for the 4K display) or to hide it completely.
As the font of grub can be very tiny on a high res display, you can create a bigger one with the following command, as described here. I chose a font size of 42 for the 4K panel.
sudo grub-mkfont --output=/boot/grub/fonts/DejaVuSansMono24.pf2 --size=42 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
Next, open the grub settings with sudo nano /etc/default/grub
and adjust it for either dual boot or single boot.
If you want to select the operating system with the UEFI boot manager by pressing F12 at startup, you can use the same settings as for the single boot setup. If you want to use grub I suggest following settings:
GRUB_DEFAULT=saved # boot the saved OS
GRUB_SAVEDEFAULT=true # save the last booted OS
GRUB_TIMEOUT=2 # time it is shown (in seconds)
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash button.lid_init_state=open" # suspend boot loop fix (see above)
GRUB_FONT=/boot/grub/fonts/DejaVuSansMono24.pf2 # choosing the created bigger font for 4k display
The first two lines will boot the last used OS, the third lines set the time in seconds the menu is shown (adjust to your own preferences), fourth line is the suspend loop fix and lastly, the previously created font.
Update grub with sudo update-grub
and reboot your system sudo reboot
.
If you are using Ubuntu as a single OS as described before, it will still recognize the system as dual boot due to the recovery partition and always load the grub bootloader on startup (but can be hidden with the following settings). After opening the grub config file with sudo nano /etc/default/grub
I used following settings:
GRUB_DEFAULT=0 # boot first entry in the list (Ubuntu)
GRUB_TIMEOUT=1 # time until grub automatically loads the chosen OS (in seconds)
GRUB_DISABLE_OS_PROBER=true # do not show grub (since it is single boot anyways)
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash button.lid_init_state=open" # suspend boot loop fix (see above)
First line choses Ubuntu as boot partition. As grub will still run in background, the timeout is set to one second (setting it to zero it will be ignored and then it takes the standard time of ten seconds). The third line hides the display output, and the last line fixes the suspend loop.
Update grub with sudo update-grub
and reboot your system sudo reboot
.
Here are the things I had problems with in Ubuntu 21.04, but worked fine with later versions.
Firefox isn’t scrolling with touch. Open the environment file with:
sudo nano /etc/environment
and add
MOZ_USE_XINPUT2=1
The OLED screen doesn’t react on brightness changes (because it doesn’t have a classic backlight as LCD-panels have). Install ICC brightness to solve the problem.
sudo apt install build-essential
sudo apt install liblcms2-dev
sudo make install
If you’re coming from a mac, you’ll probably miss the gestures on the touchpad. The best I could find was Touchegg, but much more customizable. For the GUI I used Touché. You might also want to check https://ubuntuhandbook.org/index.php/2021/06/multi-touch-gestures-ubuntu-20-04/
Now for the interesting part.
I like to use Miniforge for my work. To download, install and create an environment called tf
run:
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh
source ~/.bashrc
conda create --name tf python=3.12
conda activate tf
pip install --upgrade pip
If you want to deactivate and remove the environment simply run:
conda deactivate
conda env remove -n tf
Setting up CUDA and TensorFlow has become easier lately. If you want to set up older versions of Ubuntu/CUDA/CuDNN have a look at an older coomit of this post.
If you didn’t choose the additional drivers during the installation of Ubuntu, activate the Nvidia Proprietary Driver in Software & Updates under Additional Drivers (nvidia-driver-535 at the time of writing) and reboot. You can display information about the GPU and the CUDA Version (12.2 for me) with:
nvidia-smi
Install the Nvidia Cuda Toolkit next:
sudo apt install nvidia-cuda-toolkit
To install the latest version of TensorFlow with GPU support simply run:
pip install tensorflow[and-gpu]
To use the TensorCores on your GPU edit your Code:
from tensorflow.keras import mixed_precision
mixed_precision.set_global_policy('mixed_float16')
I get roughly a 30% speedup. Nice.
Installing Nvidia CuDNN isn’t necessary anymore when installing TensorFlow as described previously. If you still want to install it for other reasons: this is the way it worked for me:
tar -xf cudnn-linux-x86_64-*.tar.xz
sudo cp cudnn-linux-x86_64-*/include/cudnn*.h /usr/lib/cuda/include/
sudo cp -P cudnn-linux-x86_64-*/lib/libcudnn* /usr/lib/cuda/lib64/
sudo chmod a+r /usr/lib/cuda/include/cudnn*.h /usr/lib/cuda/lib64/libcudnn*
echo 'export LD_LIBRARY_PATH=/usr/lib/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/lib/cuda/include:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
Reboot and everything should work. In some cases, after reboot the Nvidia drivers were greyed out in Software & Updates and TensorFlow was using the CPU. Running sudo ubuntu-drivers install
and rebooting solved the problem.
When you use X11 instead of Wayland and run nvidia-smi
you should see one process called /usr/lib/xorg/Xorg
. This is the display protocol that is being processed by the discrete GPU. If you want to ran that on the low-powered iGPU (Intel) and use the dGPU just for processing, do the following (updated from here):
Open the Nvidia config file e.g. with sudo nano /etc/modprobe.d/nvidia-graphics-drivers-kms.conf
and add the following lines to the end:
blacklist nvidia_drm
blacklist nvidia_modeset
install nvidia_drm /bin/false
install nvidia_modeset /bin/false
After rebooting try using nvidia-smi
. There should not be any Xorg processes listed anymore
I you found a way to do the same for Wayland let me know!
The RTX 3080 supports Nvidia On-Demand, so your notebook will mainly use the Intel GPU and use the dedicated one only if needed. Go to NVIDIA X Server Settings and set the PRIME Profiles to NVIDIA On-Demand. You can also do this via Terminal with prime-select
, for example
sudo prime-select on-demand
(also helpful if Intel only is greyed out)
You can specifiy which applications should use the Nvidia GPU under:
sudo nano /etc/environment
for Vulkan applications add
__NV_PRIME_RENDER_OFFLOAD=1
It can be tested by installing sudo apt install vulkan-tools
and run vkcube
.
for GLX applications add
__NV_PRIME_RENDER_OFFLOAD=1
__GLX_VENDOR_LIBRARY_NAME=nvidia
Testing OpenGL can be done by installing sudo apt install glmark2
and running glmark2
.
To check which GPU is currently being used:
glxinfo | grep vendor
For Ubuntu 21.04: In some cases Ubuntu switched back to Wayland for the desktop, which is not supported by Nvidia, so it would always rely on the Intel GPU. To always use Xorg uncomment the line:
sudo nano /etc/gdm3/custom.conf
WaylandEnable=false
With Nvidia On-Demand my battery life increased under light load from two hours to nearly seven hours.
Matlab doesn’t scale automatically for 4K-panels. In the command window run:
s = settings;s.matlab.desktop.DisplayScaleFactor
s.matlab.desktop.DisplayScaleFactor.PersonalValue = 2
Carla is the only application so far that made minor troubles while installing under Ubuntu 21.04.
When adding the repository replace $(lsb_release -sc) with focal:
pip install --user pygame numpy
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1AF1527DE64CB8D9
sudo add-apt-repository "deb [arch=amd64] http://dist.carla.org/carla focal main"
sudo apt update
sudo apt install carla-simulator
I added support for the Razer Blade Advanced Early 2021 to OpenRazer. As my pull request got merged you can install it simply as described here:
sudo add-apt-repository ppa:openrazer/stable
sudo apt update
sudo apt install openrazer-meta
Don’t forget to add your user to the plugdev group with sudo gpasswd -a $USER plugdev
.
For the GUI I use Polychromatic. Install with:
sudo add-apt-repository ppa:polychromatic/stable
sudo apt install polychromatic
Reboot and you’re ready to go!
Weirdly, when the tray applet is running and I put the laptop to sleep and wake again, the backlight is turned off until after login. Not sure if it is a bug, but it makes it difficult logging in in the dark. I just turned the applet of in startup scripts and that solved the problem.
PulseEffect got updated and is called EasyEffects now. Installation got a little bit more complicated now.
The Blade has probably the worst sounding speaker I have heard since my first mobile phone in the mid 2000s! Luckily, there is EasyEffects! If you haven’t install Flatpak do so with
sudo apt install flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
and then install EasyEffects
flatpak install flathub com.github.wwmm.easyeffects
You need the run following commands as described here:
sudo apt install pipewire-audio-client-libraries libspa-0.2-bluetooth libspa-0.2-jack
sudo apt install wireplumber pipewire-media-session-
Reboot and run start the application.
I spent way too much time tweaking the equalizer and the outcome is actually pretty good (screenshot still from PulseEffects, EasyEffects looks similar):
The .json file in this repo was exported from PulseEffect and does not work properly at the moment, I will look into it. Start service at login from the settings does not work at the moment. A workaround is explained in the issues. Create the file com.github.wwmm.easyeffects.desktop
in ~/.config/autostart
for example with:
sudo nano ~/.config/autostart/com.github.wwmm.easyeffects.desktop
and add
[Desktop Entry]
Name=EasyEffects
Comment=EasyEffects Service
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=easyeffects com.github.wwmm.easyeffects --gapplication-service
Icon=easyeffects
StartupNotify=false
Terminal=false
Type=Application
The Blade Advanced features an IR camera for Windows Hello. You can use it for face recognition, so you don’t need to type your password after sudo or on the login screen. Install Howdy with
sudo add-apt-repository ppa:boltgolt/howdy
sudo apt update
sudo apt install howdy
and in the setting sudo howdy config
change the device path to device_path = /dev/video2
(video0 is the normal camera, video2 the IR sensor) and set ignore_closed_lid = false
. Then add your face:
sudo howdy add
sudo howdy test
There seems to be a problem at some times, when the IR light doesn’t turn on. Apparently, by booting from the bios the problem does not occur anymore.
I haven’t heard so far, whether the OLED screen suffers of burn-in or not. But it doesn’t hurt to take a little care.
Black Wallpaper. ou can remove the wallpaper and have a blank background. Use dconf Editor or Terminal and set the background color to black with gsettings set org.gnome.desktop.background primary-color "#000000"
, remove the wallpaper with gsettings set org.gnome.desktop.background picture-uri ""
for light mode and gsettings set org.gnome.desktop.background picture-uri-dark ""
for dark mode.
Hide Mouse Cursor. To hide the mouse cursor when idling, install Unclutter with sudo apt install unclutter
. Then, add the command unclutter
to the startup applications. Only works correctly with X11.
Hide the Dock. One option is to go into the settings and set the dock to “auto-hide”, then it will only appear when dragging the mouse to the side of the screen. To completely remove it you can install Gnome Extensions from Ubuntu Software and turn the dock off. Then, it will only be visible in the activities overview when pressing the super key (the windows key in the case of the Blade).
Hide the Top Bar. Lastly, to hide the top bar you can install the gnome extension Hide Top Bar. Activate it and set the two Intellihide options off.
Hide Home and Trash Icon. When gnome extension is installed, you can also remove the icons from the desktop. Just right-click in the desktop, choose settings and turn off the toggles for personal folder and trash.
With Ubuntu 21.04 it didn’t really work to connect Airpods to the notebook. A fix can be found here.