Skip to content

Instantly share code, notes, and snippets.

@TysonRayJones
Last active April 4, 2024 14:45
Show Gist options
  • Save TysonRayJones/29a1f3a4f773dbe3aaae36a65343830b to your computer and use it in GitHub Desktop.
Save TysonRayJones/29a1f3a4f773dbe3aaae36a65343830b to your computer and use it in GitHub Desktop.
How to connect an NVIDIA eGPU to OSX

Using an NVIDIA eGPU with OSX

Installation Instructions

Connecting the eGPU

Do not connect the eGPU to your Macbook until instructed.

1 . Update to macOS High Sierra, version 10.13.5 Do this by Apple > About This Mac > Software Update...

  1. Connect only the eGPU to your Macbook (connect cable then switch on). Ensure no other devices are connected by thunderbolt 3. You should see the Akitio Node under Apple > (holding option) System Information... > Thunderbolt

  2. Install the macOS-eGPU drivers. This is done by

    1. restart and hold command + R This boots into recovery mode
    2. open Utilities > Terminal
    3. enter csrutil disable; reboot
    4. after reboot, disconnect the eGPU
    5. open terminal and enter bash <(curl -s https://raw.githubusercontent.com/learex/macOS-eGPU/master/macOS-eGPU.sh) and follow instructions
  3. when finished, reconnect the eGPU then restart

  4. you should see two new icons at the top of your computer, once which mentions your GPU name when clicked.

  5. check the GPU name (e.g. Quadro P6000) appears under Apple > (holding option) System Information... > Graphics/Displays

Say NO to any NVIDIA driver update window

  1. Disable auto-NVIDIA updating, which will relentlessly break everything. Click the new NVIDIA icon in the toolbar > Open NVIDIA Driver Manager Preferences > Updates, then disable Automatically check for updates (may have to unlock via bottom left first).

Installing a CUDA compiler

If you want to write programs for the GPU (e.g. use QuEST) you'll need the NVIDIA compiler nvcc, which wraps around an existing compiler on your machine. Unfortunately nvcc doesn't support modern Clang (default compiler on OSX) nor GNU compilers (e.g. gcc 4.9 that non-GPU QuEST recommends)

We'll instead use Clang 3.7. Note Clang doesn't support OpenMP so you won't be able to simultaneously use CPU parallelism. This may mean you'll later need to remove #include <omp.h> from your library code.

If you don't have Homebrew, download it via

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Next, try

brew install llvm37

If that fails with an xcrun error, repeat after trying

sudo xcode-select --install

or search for alternate v3 versions with

brew search llvm

Check installation was successful by entering

clang++-3.7 --version

though this may require first adding clang-3.7 to your path. Instructions should be displayed in the brew output, and require closing and reopening a new Terminal after following.

We're now ready to install nvcc.

brew tap caskroom/drivers
brew cask install nvidia-cuda

This will open a dialogue window at some point during installation.

Check nvcc was installed successfully via

/usr/local/cuda/bin/nvcc --version

To make nvcc a recognised command, edit /etc/profile via

sudo nano /etc/profile

and add to the bottom:

# resolving nvcc to use GPU
export PATH=/Developer/NVIDIA/CUDA-9.0/bin${PATH:+:${PATH}}
export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-9.0/lib\ {DYLD_LIBRARY_PATH:+:$$
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export PATH=/usr/local/bin:$PATH

Exit and save (ctrl-x then y then Enter), then run

source /etc/profile

Test nvcc is recognised

nvcc --version

Usage Instructions

Caution It is important to turn off your computer when connecting or disconnecting the eGPU. Otherwise, applications being rendered by the GPU may crash, including your OS.

Compiling GPU code

When compiling with nvcc, you'll need to tell it to wrap Clang 3.7 using the ccbin flag:

nvcc -ccbin clang++-3.7 ...
@TysonRayJones
Copy link
Author

Hi there,

I'm certainly no expert, but maybe we can work it out. What version of MacOS are you running?
You should be aware that apple refused to validate NVIDIA drivers for Mojave and later (see here).

@dmitchell78
Copy link

dmitchell78 commented Oct 26, 2020 via email

@TysonRayJones
Copy link
Author

Hi Dennis,

Sounds like everything's actually set up fine. If you're using the eGPU as a GPGPU (like this guide is for), you can run nvidia-smi at the command line to check the GPU is targetable by nvcc.

If you're using the eGPU to render for an external monitor, then be sure to connect the GPU directly to your external monitor (with no connection to your computer), e.g. with a DP cable. It will then be impossible for your internal GPU to render for the external monitor. Note that I don't know whether it's possible for MacOS to continue rendering one monitor using the internal card, and an external monitor using the eGPU - it's certainly seems impossible on Windows (where the internal monitor must be disabled).

Hope this helps!

@dmitchell78
Copy link

dmitchell78 commented Oct 26, 2020 via email

@TysonRayJones
Copy link
Author

Hmm I'm afraid I can't be much more help - I've used the eGPU only as a display driver on Windows through bootcamp (disabling the Macbook display). On MacOS, I've used the eGPU strictly as a workstation for simulations. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment