CUDA Examples but ported to work with ROCM/HIP.
This repository requires an AMD GPU and preferably ROCM 5.4.x or higher toolchain to run. See ROCM Documentation on how to get started.
When I tried installing it on some distributions, AMD ROCM's Installer was giving me a hard time. To that goal, I had simplified some of the steps required to launch this on any Linux Distribution, worked with AMD's ROCM Examples and supplied patches to make it easy to anybody to build and run it.
This documentation was written before AMD created official Docker Images.
Follow the Documentation on the Docker Hub or ROCM Documentation Instead. This method is for those who have the penchant for more pain:
-
Ensure you have the
amdgpu
driver and the card running on your Linux Distribution. Verify that it shows up in thelsmod
command. You will need all theGPU Firmware
to be in/lib/firmware
in order for the whole shebang to run well. -
Install Docker on your Linux Distribution.
-
Scroll down to the steps found in this GitHub Gist. Use the Scripts given to get your Docker running.
-
Download the scripts from the Gist and build the
rocm-examples
container. -
Git clone this repository on your computer. From within this directory, run:
./Scripts/launch-hipmc.sh
-
You will be in a Docker Container named
hip-examples
and with everything ready to go. You will see this Git repository mounted/workspace/hip-examples
and this README within it. -
Now you can get to work, follow the course.
For most programs, you just run hipcc
. The invocation is very
similar to nvcc
.
cd 01-Hello
hipcc -o 01-Hello.out 01-Hello.hip \
-I ../Common ../Common/*.cpp ../Common/*.hip
./01-Hello.out
Things like rocprof
are there to profile those applications, but do not have the
same amount of robustness as nvprof
.
For most CUDA API calls, most things are cu
or cuda
replaced by hip
. I've
ported the cudaCommon.cu[h]
to hipCommon.hip[h]
in the Common/
directory.
I currently do not have a CUDA compatible card. During the pandemic, the NVIDIA card prices were insane due to the miners. I ended up getting a RX 6900XT at sale price (wasn't cheap either). Hence, I decided to make the best of this course.
The next thing is that in order to really learn something, typing the whole thing out by hand helps. Despite the best efforts needed to run most CUDA code as-is on HIP, doing it manually is indeed helping me learn most calls well.
So if you are taking that course, you need to ideally create your own repo. In case you do get stuck, this one will be your reference.
This code is in no way perfect or bug-free. Pull requests welcome.
Reach out to me for any feedback.
Now Enjoy!
- Author: Karthik Kumar Viswanathan
- Web : https://karthikkumar.org
- Email : me@karthikkumar.org