How can i use cuda with switchable graphics (not using bumblebee)

everything seems fine, though i would like to confirm somehow with an actual test. session is running on intel and nvidia-smi shows the nvidia card available, blender shows the nvidia for cuda in preferences. but im still unable to find an actual test to run on cuda to confirm it's working properly. i just ran blender for the first time ever about 10 minutes ago so i know not what im doing :sweat_smile:

the only tool in the aur i could find is not working properly, not just for me but in general it's not working.

@LangoLango, you should probably edit the thread title. optimus-manager and bumblebee together might create a singularity and swallow the earth we live on :laughing:

I dunno, just install xmrig-nvidia (AUR), it needs cuda to run properly and builds very fast so you'll know if cuda works simply by running that as command in terminal.

1 Like

XMRig is high performance Monero (XMR) NVIDIA miner, with the official full Windows support.

GPU mining part based on psychocrypt code used in xmr-stak-nvidia.

thanks, never even thought to use a crypto miner to test it. seems to work fine

after stopping miner and unloading nvidia modules:

2 Likes

Nice, this means cuda works. How did you make nvidia load? Simply modprobed it? I don't remember optimus-switch settings, does it blacklist or alias nvidia in Intel mode?

the original optimus-switch setup would load the nvidia modules to /bin/false so thay cant be used

original /etc/switch/intel/intel-modprobe.conf
#blacklists all nouveau/nvidia modules
#so they are not loaded.

blacklist nouveau
blacklist ttm
install nvidia /bin/false
install nvidia-modeset /bin/false
install nvidia-drm /bin/false
install nvidia-uvm /bin/false

#######################################
#this following section can be removed#
#if you plan to use the modesetting   #
#driver intead of the intel driver    #
#######################################

#stops display from "blinking" or "flashing"
#during boot when using the intel driver.

options i915 enable_fbc=1
options i915 fastboot=1
modified /etc/switch/intel/intel-modprobe.conf
#blacklists all nouveau/nvidia modules
#so they are not loaded.

blacklist nouveau
blacklist ttm
#install nvidia /bin/false
install nvidia-modeset /bin/false
install nvidia-drm /bin/false
#install nvidia-uvm /bin/false

#######################################
#this following section can be removed#
#if you plan to use the modesetting   #
#driver intead of the intel driver    #
#######################################

#stops display from "blinking" or "flashing"
#during boot when using the intel driver.

options i915 enable_fbc=1
options i915 fastboot=1

this allows nvidia and nvidia-uvm to be loaded if needed, but not nvidia-modeset and nvidia-drm so they wont interfere with display function.

3 Likes

@dglt Nice bit of detective work there. I learned something new. Thanks!

Is this something you may think about changing in your Optimus-Switch package?

1 Like

i actuall just did some more tinkering and im thinking of maybe including an alternate setup that allows for switching without reboot and would also allow for cuda. it's not setup this way now because i found it to be too unstable like optimus-manager. it works for me as i just tested it again but my gpu also shuts itself off when the nvidia modules are unloaded and power management set to auto. that said i could just include an alternate setup that users could enable and see if it works for them and if not can use the default setup requiring a reboot as it is now. this way it's flexible without over complicating everything.

maybe in the next few days if im feeling ambitious i'll throw something together, thanks for volunteering for lab rat duty @linesma :sweat_smile:. you were the first optimus-switch lab rat other than myself after all.

2 Likes

@dglt Let me drink a couple of beers first to build my courage up!!!

2 Likes

i dont feel like doing it now, but i'll let you know when it's ready to test.

1 Like

@dglt Thanks. I have had enough of nVidia lately. I had to reformat my Shield TV and set it back up.... talk about frustration!

Ok, I did install Manjaro without MHWD, and I am using it right now. What should be the next step if I want to use @dglt solution?

Sorry, I saw now that I need to install video-nvidia, but MHWD is just freezing... I will try to update all packages first.

follow the directions on the optimus-switch github readme.

if your using kde/sddm then it's

after you get it setup and working the way it's meant to work, then make the edits i suggested before for cuda to work. if you need help after it's setup i'll explain but first just set it up the way it's intended to be.

1 Like

I got a black screen. :joy:

I guess I didn't update the kernel, and the acpi_call package failed to install.

so where are you at right now? another device?

yeah, a full system update first is important.

sudo pacman-mirrors -f8 ; sudo pacman -Syyu

then make sure the packages that need to be installed are actually installed. assuming your using the 4.19 lts kernel, those packages would be

linux419-nvidia
linux419-headers
dkms
acpi_call-dkms
xf86-video-intel
xorg-xrandr

if you cant get to a desktop, use ctrl+alt+f2 to get to a TTY and do what needs to be done.

2 Likes

Ok, now it is working...

I did the modification you said before, but when I try to run nvidia-smi nothing happens... The terminal window just froze up.

What I did:

  • I commented the last line in no-optimus.sh file.
  • I updated the intel-modprobe.conf with your modifications.

ok, so both intel and nvidia modes are working? if not, make sure first that both of them work before changing anything.

this is from intel mode im assuming? if yes, post these outputs from intel mode

mhwd -li
ls -laR /etc/X11
cat /etc/X11/xorg.conf.d/*.conf
ls -la /etc/modprobe.d ; cat /etc/modprobe.d/*.conf
ls -la /etc/modules-load.d ; cat /etc/modules-load.d/*.conf

Both modes are working, and nvidia-smi works on Nvidia mode.

Output of mhwd -li from Intel session:

> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
          video-nvidia            2018.08.09               false            PCI


Warning: No installed USB configs!
ls -laR /etc/X11

/etc/X11:
total 32
drwxr-xr-x  5 root root 4096 Mar 12 04:39 .
drwxr-xr-x 89 root root 4096 Aug  7 11:13 ..
drwxr-xr-x  2 root root 4096 Aug  7 09:37 mhwd.d
drwxr-xr-x  3 root root 4096 Mar 12 04:40 xinit
drwxr-xr-x  2 root root 4096 Aug  7 11:07 xorg.conf.d

/etc/X11/mhwd.d:
total 12
drwxr-xr-x 2 root root 4096 Aug  7 09:37 .
drwxr-xr-x 5 root root 4096 Mar 12 04:39 ..

/etc/X11/xinit:
total 28
drwxr-xr-x 3 root root 4096 Mar 12 04:40 .
drwxr-xr-x 5 root root 4096 Mar 12 04:39 ..
-rw-r--r-- 1 root root  739 Mar  4 12:31 xinitrc
drwxr-xr-x 2 root root 4096 Aug  7 10:28 xinitrc.d
-rw-r--r-- 1 root root   45 Mar  4 12:31 xserverrc

/etc/X11/xinit/xinitrc.d:
total 20
drwxr-xr-x 2 root root 4096 Aug  7 10:28 .
drwxr-xr-x 3 root root 4096 Mar 12 04:40 ..
-rwxr-xr-x 1 root root  318 Nov  9  2018 40-libcanberra-gtk-module.sh
-rwxr-xr-x 1 root root  203 Jul 21 00:38 50-systemd-user.sh

/etc/X11/xorg.conf.d:
total 20
drwxr-xr-x 2 root root 4096 Aug  7 11:07 .
drwxr-xr-x 5 root root 4096 Mar 12 04:39 ..
-rw-r--r-- 1 root root  301 Aug  7 09:18 00-keyboard.conf
-rw-r--r-- 1 root root  672 Aug  7 11:07 99-intel.conf
cat /etc/X11/xorg.conf.d/*.conf

# Read and parsed by systemd-localed. It's probably wise not to edit this file
# manually too freely.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us"
        Option "XkbModel" "pc105"
        Option "XkbVariant" "intl"
EndSection
# xorg configuration for use with intel driver.
# xf86-video-intel package required
#
# This driver now uses DRI3 as the default Direct Rendering
# Infrastructure. You can try falling back to DRI2 if you run
# into trouble. To do so, save a file with the following 
# content as /etc/X11/xorg.conf.d/20-intel.conf :
 
    Section "Device"
        Identifier  "Intel Graphics"
        Driver      "intel"
        Option      "DRI" "3"             # DRI2 and DRI1 are alternatives if DRI3 performs performs poorly
        Option      "TearFree" "true"
        #Option      "AccelMethod"  "sna" # default
        #Option      "AccelMethod"  "uxa" # fallback
     EndSection

ls -la /etc/modprobe.d ; cat /etc/modprobe.d/*.conf

total 16
drwxr-xr-x  2 root root 4096 Aug  7 11:07 .
drwxr-xr-x 89 root root 4096 Aug  7 11:13 ..
-rw-r--r--  1 root root  560 Aug  7 11:07 99-intel.conf
#blacklists all nouveau/nvidia modules
#so they are not loaded.

blacklist nouveau
blacklist ttm
#install nvidia /bin/false
install nvidia-modeset /bin/false
install nvidia-drm /bin/false
#install nvidia-uvm /bin/false

#######################################
#this following section can be removed#
#if you plan to use the modesetting   #
#driver intead of the intel driver    #
#######################################

#stops display from "blinking" or "flashing"
#during boot when using the intel driver.

options i915 enable_fbc=1
options i915 fastboot=1
ls -la /etc/modules-load.d ; cat /etc/modules-load.d/*.conf

total 16
drwxr-xr-x  2 root root 4096 Aug  7 11:07 .
drwxr-xr-x 89 root root 4096 Aug  7 11:13 ..
-rw-r--r--  1 root root   34 Sep 30  2018 modules.conf
# List of modules to load at boot

please also post

cat /usr/local/bin/optimus.sh
lsmod | grep nvidia
cat /usr/local/bin/optimus.sh

This file does not exist in my system.

lsmod | grep nvidia

nvidia              18874368  0
ipmi_msghandler        69632  2 ipmi_devintf,nvidia

Forum kindly sponsored by Bytemark