Skip to content

Instantly share code, notes, and snippets.

@ca4ti
Forked from TysonRayJones/nvidia_gpu_on_osx.md
Created March 21, 2024 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ca4ti/423a2e619849b724e65eb348c5227ddc to your computer and use it in GitHub Desktop.
Save ca4ti/423a2e619849b724e65eb348c5227ddc 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 ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment