Skip to content

Support gpu#42

Open
xllgit wants to merge 2 commits intomainfrom
support_GPU
Open

Support gpu#42
xllgit wants to merge 2 commits intomainfrom
support_GPU

Conversation

@xllgit
Copy link
Collaborator

@xllgit xllgit commented Mar 19, 2024

This branch support GPU and need install CUDA and change libtorch-cpu to libtorch-gpu.

Copy link
Collaborator

@lixi-zhou lixi-zhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CUDA code looks good to me. Please see the comments for the library configuration, thank you.

endif

NUM_THREADS ?= $(shell getconf _NPROCESSORS_CONF 2>/dev/null || echo 1)
#NUM_THREADS ?= $(shell getconf _NPROCESSORS_CONF 2>/dev/null || echo 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please discard the hard-coded num_threads, it should be set automatically

target_link_libraries(velox_gpu_hash_table_test Folly::folly gflags::gflags)
set_target_properties(velox_gpu_hash_table_test PROPERTIES CUDA_ARCHITECTURES
native)
75)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please clarify the reason for the changes as well as the following similar changes.


find_package(Torch REQUIRED)
find_package(xgboost REQUIRED)
find_package(CUDA REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may lead to a compilation error when comping in a CPU-only option. I see Velox provides a flag, VELOX_ENABLE_GPU. I think it would be better to cooperate this configuration code with the flag, VELOX_ENABLE_GPU

@@ -0,0 +1,53 @@
#include "velox/ml_functions/gpufunctions.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move your .cu file to the ml_functions folder.

@xllgit
Copy link
Collaborator Author

xllgit commented Mar 19, 2024 via email

@lixi-zhou
Copy link
Collaborator

Hi Lixi, In Makefile, I hard-coded the num-threads because I met the out-of-memory problem when I used all the threads. I mistakenly uploaded this file, and I can change it. set_target_properties(velox_gpu_hash_table_test PROPERTIES CUDA_ARCHITECTURES - native) + 75) The reason why I changed "native" to '75' is because CMake does not support 'native' before version 3.24, The CMakeLists doesn't need to change if you use CMake 3.24 or above. https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html

Thanks for the feedback. In Velox, I think we can leverage this line's code: CMakeLists.txt#L371 to automatically set the cuda architecture.

find_package(CUDA REQUIRED) For now, we used the 'use_gpu' flag and mixed the cuda code and CPU code, To compile the GPU function, the cuda package is necessary. If we want to compile in a CPU-only option, I think one way is to separate the Matrix multiply class into two versions(CPU and GPU), another way is we compile the GPU function first and provide it by a library.

Yes, I agree with you. Let me think about this and get back to you later about how to resolve it more conveniently.

@xllgit
Copy link
Collaborator Author

xllgit commented Mar 20, 2024

Thanks for the feedback. In Velox, I think we can leverage this line's code: CMakeLists.txt#L371 to automatically set the cuda architecture.

Yeah, but it did not work for me. CMake did not set the Cuda architecture, so I hard-coded it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants