blog

RSS
[TAGGED: Windows]
  1. Install Stable Diffusion in WSL with AMD Radeon ROCm

    Recently released Adrenalin 24.12.1 driver unlocks new AI-related potential!

    Recently when upgrading my AMD Adrenalin driver, a line in the release notes piqued my interest:

    Official support for Windows Subsystem for Linux (WSL 2) enables users with supported hardware to develop with AMD ROCm™ software on a Windows system, eliminating the need for dual boot set ups.

    Historically, AMD ROCm support has been pretty limited compared to NVIDIA CUDA, which has worked in Windows Subsystem for Linux (WSL 2) for awhile. So this new driver seemed like kind of a big deal, and I thought I'd check it out!

    AMD's article is short and sweet. Obviously you'll need the latest AMD Adrenalin Edition GPU driver installed, and also Windows Subsystem for Linux. Microsoft's official documentation is good, and I've gone through my own installation experience here.

    Once you have the amdgpu driver installed, you can run rocminfo to confirm everything is working. You should see output like this:

    *******
    Agent 2
    *******
      Name:                    gfx1100
      Marketing Name:          AMD Radeon RX 7900 XTX
      Vendor Name:             AMD
      Feature:                 KERNEL_DISPATCH
      Profile:                 BASE_PROFILE

    Installing the Stable Diffusion Web UI is also easy. You'll need Python 3.10 and Git installed (sudo apt install python3 git) if you don't already. Then just pick an installation folder and clone the stable-diffusion-webui repository to your local machine: git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

    Fixing AMD-specific problems in Stable Diffusion

    Once you have the Stable Diffusion code, you should be able to run ./webui-sh to start the Web UI. However, more than likely you'll run into a couple of specific errors that prevent it from starting:

    • Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'

      By default, PyTorch is trying to talk to the NVIDIA CUDA driver. Obviously on an AMD GPU, that's not going to work. Helpfully, this error message tells us how to fix the problem.

    • RuntimeError: "addmm_impl_cpu" not implemented for 'Half'

      I'm not sure if this is a driver bug or what, but apparently half-precision mode isn't working under ROCm. You can fix this by adding --precision full --no-half to your COMMANDLINE_ARGS.

    To fix both problems, simply edit your webui-user.sh file, find and un-comment the line (remove the leading #) with export COMMANDLINE_ARGS, and customize it like so:

    export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half"

    Edit webui-user.sh with GNU nano

    Save the file, and now you should be able to ./webui-sh to start the Web UI and begin generating images with your AMD Radeon GPU! Once the Web UI is running, you can open it in your browser by navigating to http://127.0.0.1:7860

    A shiba inu sitting at a table, no methamphetamines

    Posted 2024-12-21 12:02:00 CST by henriquez. Comments
  2. How to mount a LUKS encrypted Linux drive in Windows

    Become the world’s top super hacker with this one weird trick

    This is kind of fun, but probably no one will need to do this ever. But the point is you can! So why not? Anyway, suppose you have an encrypted Linux drive and you want to mount it in Windows for whatever reason. Just follow along.

    1. Install Windows Subsystem for Linux 2

      WSL 2 allows you to run a virtualized Linux environment that integrates tightly with the Windows OS. To install it, search for "Turn Windows features on or off" in the Start menu and click the shortcut to open the Settings pane. Scroll down towards the bottom and check the box for "Windows Subsystem for Linux". Then click "OK" to install WSL 2.

    2. Open the Microsoft Store app and install Ubuntu Linux 22.04 LTS

      This is trippy as hell. Ubuntu Linux on an App Store? We have entered the end times indeed.

      Screenshot of Microsoft Store app

    3. Confirm it worked by opening Linux in Windows Terminal

      Start the Terminal app, which should be pre-installed. By default it will probably open to a Powershell or Command Prompt. Click the dropdown arrow on the tab bar and you should see "Ubuntu 22.04.2 LTS" or something similar in the dropdown menu. Click it to start Linux!

      Screenshot of Windows Terminal app

    4. Run an Administrator Powershell and give WSL 2 access to your physical drive

      These instructions are adapted from Microsoft's own documentation so check that out if you need help. Basically, open a new Powershell as Administrator (right click the shortcut and then "Run as administrator").

      List your physical drives by entering: GET-CimInstance -query "SELECT * from Win32_DiskDrive"

      The command should give you output similar to the following:

      DeviceID           Caption                   Partitions Size          Model
      --------           -------                   ---------- ----          -----
      \\.\PHYSICALDRIVE3 Samsung SSD 980 PRO 2TB   1          2000396321280 Samsung SSD 980 PRO 2TB
      \\.\PHYSICALDRIVE0 WD_BLACK SN850X 4000GB    3          4000784417280 WD_BLACK SN850X 4000GB
      \\.\PHYSICALDRIVE1 Samsung SSD 970 PRO 512GB 1          512105932800  Samsung SSD 970 PRO 512GB
      \\.\PHYSICALDRIVE2 WDBRPG0020BNC-WRSN        1          2000396321280 WDBRPG0020BNC-WRSN

      So, one of the DeviceIDs in the output should map to your LUKS encrypted Linux. Suppose for example it was \\.\PHYSICALDRIVE3, then you can give your WSL 2 environment access to that drive with the following commmand:

      wsl --mount \\.\PHYSICALDRIVE3 --bare

      PROTIP — If you need to do this a lot, you can put that command in a .bat file and run it (as Administrator) anytime you want to mount the drive in WSL 2.

    5. Find your encrypted drive in your WSL 2 shell

      Go back to your Terminal with the Ubuntu Linux shell running, and if everything worked, you should be able to find your encrypted drive with the following command: lsblk -l

      The command should give you output similar to the following:

      NAME          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
      sda             8:0    0 363.3M  1 disk
      sdb             8:16   0     8G  0 disk  [SWAP]
      sdc             8:32   0     1T  0 disk  /snap
                                               /mnt/wslg/distro
                                               /
      sdd             8:48   0     2T  0 disk
      sdd1            8:49   0     2T  0 part

      In this example the sdd1 identifier maps to the encrypted partition on your physical drive.

    6. Decrypt and mount the encrypted drive

      You will need a package called cryptsetup if it's not installed. From your Linux shell, enter sudo apt install cryptsetup if needed.

      Now you can decrypt the volume by entering (for example): sudo cryptsetup luksOpen /dev/sdd1 samsung_980_pro

      ^ The name you put in the last argument of that command is any arbitrary name you want to assign the drive in the device mapper. Just be sure that you use the correct device name for the encrypted partition listed from lsblk (in this example /dev/sdd1).

      Once it's decrypted, you can mount the drive with the following command(s):

      • sudo mkdir /mnt/my_encrypted_drive (if needed)
      • sudo mount /dev/mapper/samsung_980_pro /mnt/my_encrypted_drive

      Obviously you can customize the names and mount location however you see fit.

    7. Now you can access your encrypted drive from Windows Explorer!

      Open a new Explorer window and scroll down the left sidebar until you see "Linux." Click this and you'll be able to browse the filesystem from your Ubuntu 22.04 installation. Simply navigate to /mnt/my_encrypted_drive or wherever you mounted the drive, and you'll have access to your encrypted volume!

      Screenshot of Windows Explorer

    One nice use case for this...

    Having an encrypted drive is just a good idea in general. If your computer is lost or stolen you can keep your private files protected and not worry so much about identity theft or any other bad outcomes from people maliciously accessing your files. Many Windows computers ship without any kind of drive encryption, and Microsoft's own BitLocker disk encryption is only available in "Pro" editions of Windows.

    Speaking of BitLocker, who can even trust that shit? It's a closed source system and Microsoft can swear up and down that it's safe and secure, but for all anyone knows it's backdoor'ed six ways from Sunday. By using Linux LUKS drive encryption in Windows, you at least have open source and provable security. Just make sure your passphrase is strong enough and you're good to go!

    Posted 2023-09-12 11:04:00 CST by henriquez. Comments
  3. My review of Pop!_OS 22.04 vs. MacOS and Windows

    TL;DR: Pop!_OS > Windows > MacOS

    I've been building and tinkering with computers since I was a small child. Originally I would salvage old computer parts that schools and businesses were throwing away, swapping broken parts for whatever working hardware I could find, in the process converting my parents' family room into a junkyard of resurrected IBM PS/2s and dot matrix printers, all of them beeping and clicking and running my childish attempt at an artificial general intelligence.

    Now that I'm grown up, my life is much the same, although instead of finding old junk, I've blown altogether way too much money buying computers and experimenting with new builds. This means I've never been a "PC guy" or a "Mac guy" or a "Linux nerd" or anything else. I'm intimately familiar with Windows, MacOS and many flavors of Linux and I appreciate all of them for what they are.

    But recently, I sold off my Windows and Mac setups and made 2023 my year of Linux on the desktop. And so far I am loving it, thanks in great part to Pop!_OS 22.04, the only Linux distro I've used that fits me like a glove. So in the following post, I will ramble on about Pop!_OS and why I took the plunge.

    Read More

    Posted 2023-08-05 23:11:00 CST by henriquez. 2 comments