Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit d7f2963

Browse files
committed
Try to fix cuda arch missing error in ci
1 parent c03d0fc commit d7f2963

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,13 @@ CFLAGS += -I$(TVM_PATH)/include -DMXNET_USE_TVM_OP=1
473473
LDFLAGS += -L$(ROOTDIR)/lib -ltvm_runtime -Wl,-rpath,'$${ORIGIN}'
474474

475475
TVM_USE_CUDA := OFF
476+
TVM_OP_CUDA_ARCH := NONE
476477
ifeq ($(USE_CUDA), 1)
477478
TVM_USE_CUDA := ON
478479
ifneq ($(USE_CUDA_PATH), NONE)
479480
TVM_USE_CUDA := $(USE_CUDA_PATH)
480481
endif
482+
TVM_OP_CUDA_ARCH = $(USE_TVM_OP_CUDA_ARCH)
481483
endif
482484
endif
483485

@@ -630,11 +632,15 @@ lib/libtvm_runtime.so:
630632
ls $(ROOTDIR)/lib; \
631633
cd $(ROOTDIR)
632634

635+
TVM_OP_COMPILE_OPTIONS = -o $(ROOTDIR)/lib/libtvmop.so
636+
ifneq ($(TVM_OP_CUDA_ARCH), NONE)
637+
TVM_OP_COMPILE_OPTIONS += --cuda-arch $(TVM_OP_CUDA_ARCH)
638+
endif
633639
lib/libtvmop.so: lib/libtvm_runtime.so $(wildcard contrib/tvmop/*/*.py contrib/tvmop/*.py)
634640
echo "Compile TVM operators"
635641
PYTHONPATH=$(TVM_PATH)/python:$(TVM_PATH)/topi/python:$(ROOTDIR)/contrib \
636642
LD_LIBRARY_PATH=$(ROOTDIR)/lib \
637-
python3 $(ROOTDIR)/contrib/tvmop/compile.py -o $(ROOTDIR)/lib/libtvmop.so
643+
python3 $(ROOTDIR)/contrib/tvmop/compile.py $(TVM_OP_COMPILE_OPTIONS)
638644

639645
NNVM_INC = $(wildcard $(NNVM_PATH)/include/*/*.h)
640646
NNVM_SRC = $(wildcard $(NNVM_PATH)/src/*/*/*.cc $(NNVM_PATH)/src/*/*.cc $(NNVM_PATH)/src/*.cc)

ci/docker/runtime_functions.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ NOSE_COVERAGE_ARGUMENTS="--with-coverage --cover-inclusive --cover-xml --cover-b
2626
NOSE_TIMER_ARGUMENTS="--with-timer --timer-ok 1 --timer-warning 15 --timer-filter warning,error"
2727
CI_CUDA_COMPUTE_CAPABILITIES="-gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_70,code=sm_70"
2828
CI_CMAKE_CUDA_ARCH_BIN="52,70"
29+
CI_CUDA_ARCH="sm_70"
2930

3031
clean_repo() {
3132
set -ex
@@ -228,7 +229,7 @@ build_ubuntu_gpu_mkldnn_release() {
228229
# $1 -> mxnet_variant: the mxnet variant to build, e.g. cpu, cu100, cu92mkl, etc.
229230
build_dynamic_libmxnet() {
230231
set -ex
231-
232+
232233
local mxnet_variant=${1:?"This function requires a mxnet variant as the first argument"}
233234

234235
# relevant licenses will be placed in the licenses directory
@@ -769,6 +770,7 @@ build_ubuntu_gpu_mkldnn_nocudnn() {
769770
USE_TVM_OP=1 \
770771
CUDA_ARCH="$CI_CUDA_COMPUTE_CAPABILITIES" \
771772
USE_SIGNAL_HANDLER=1 \
773+
USE_TVM_OP_CUDA_ARCH="$CI_CUDA_ARCH $CI_CUDA_COMPUTE_CAPABILITIES" \
772774
-j$(nproc)
773775
}
774776

@@ -948,7 +950,7 @@ cd_unittest_ubuntu() {
948950
fi
949951

950952
$nose_cmd $NOSE_TIMER_ARGUMENTS --verbose tests/python/unittest
951-
$nose_cmd $NOSE_TIMER_ARGUMENTS --verbose tests/python/quantization
953+
$nose_cmd $NOSE_TIMER_ARGUMENTS --verbose tests/python/quantization
952954

953955
# https://github.com/apache/incubator-mxnet/issues/11801
954956
# if [[ ${mxnet_variant} = "cpu" ]] || [[ ${mxnet_variant} = "mkl" ]]; then

contrib/tvmop/compile.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import os
2323
import argparse
2424
from tvmop.opdef import __OP_DEF__
25+
from tvm.autotvm.measure.measure_methods import set_cuda_target_arch
26+
2527

2628
def get_target(device):
2729
if device == "cpu":
@@ -37,6 +39,8 @@ def get_target(device):
3739
parser = argparse.ArgumentParser(description="Generate tvm operators")
3840
parser.add_argument("-o", action="store", required=True, dest="target_path",
3941
help="Target path which stores compiled library")
42+
parser.add_argument('--cuda-arch', type=str, default=None, dest='cuda_arch',
43+
help='The cuda arch for compiling kernels for')
4044
arguments = parser.parse_args()
4145

4246
func_list_llvm = []
@@ -52,8 +56,9 @@ def get_target(device):
5256
binds=operator_def.get_binds(args))
5357
func_list.append(func_lower)
5458

55-
lowered_funcs = {get_target("cpu") : func_list_llvm}
59+
lowered_funcs = {get_target("cpu"): func_list_llvm}
5660
if len(func_list_cuda) > 0:
5761
lowered_funcs[get_target("cuda")] = func_list_cuda
62+
set_cuda_target_arch(arguments.cuda_arch)
5863
func_binary = tvm.build(lowered_funcs, name="tvmop")
5964
func_binary.export_library(arguments.target_path)

make/config.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ ADD_CFLAGS =
6565
# whether to build operators written in TVM
6666
USE_TVM_OP = 0
6767

68+
# specify the CUDA ARCH compilation flag for building
69+
# operator kernels implemented using TVM
70+
USE_TVM_OP_CUDA_ARCH = NONE
71+
6872
#---------------------------------------------
6973
# matrix computation libraries for CPU/GPU
7074
#---------------------------------------------

0 commit comments

Comments
 (0)