Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* build all kernel variants we may need
* ignore generated nvenc7 pyd
* remove nvapi code and use pynvml instead
* better CUDA kernel loading error messages

git-svn-id: https://xpra.org/svn/Xpra/trunk@14825 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jan 21, 2017
1 parent c87635f commit 2cff3bd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 93 deletions.
8 changes: 1 addition & 7 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def is_msvc():
# * wheezy: 53.35
csc_swscale_ENABLED = DEFAULT and pkg_config_ok("--exists", "libswscale", fallback=WIN32)
nvenc7_ENABLED = DEFAULT and BITS==64 and pkg_config_ok("--exists", "nvenc7")
nvapi_ENABLED = DEFAULT and BITS==64 and pkg_config_ok("--exists", "nvapi")
csc_libyuv_ENABLED = DEFAULT and pkg_config_ok("--exists", "libyuv", fallback=WIN32)

#Cython / gcc / packaging build options:
Expand All @@ -211,7 +210,7 @@ def is_msvc():

#allow some of these flags to be modified on the command line:
SWITCHES = ["enc_x264", "enc_x265", "enc_ffmpeg",
"nvenc7", "nvapi",
"nvenc7",
"vpx", "pillow",
"v4l2",
"dec_avcodec2", "csc_swscale",
Expand Down Expand Up @@ -2175,11 +2174,6 @@ def osx_pkgconfig(*pkgs_options, **ekw):

toggle_packages(nvenc7_ENABLED, "xpra.codecs.nvenc7")
toggle_packages(nvenc7_ENABLED, "xpra.codecs.cuda_common", "xpra.codecs.nv_util")
if nvapi_ENABLED:
cython_add(Extension("xpra.codecs.nvapi_version",
["xpra/codecs/nvapi_version.pyx"],
**pkgconfig("nvapi")
))

if nvenc7_ENABLED:
#find nvcc:
Expand Down
11 changes: 8 additions & 3 deletions src/win32/BUILD_CUDA_KERNEL.BAT
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ SET CUDA_SRC=xpra\codecs\cuda_common\%KERNEL%.cu
SET CUDA_BIN=xpra\codecs\cuda_common\%KERNEL%.fatbin

REM nvcc -fatbin -c %CUDA_SRC% -o %CUDA_BIN% --use-local-env --cl-version %CL_VERSION% -gencode=arch=compute_62,code=sm_62 --machine 64 -v
ECHO nvcc -fatbin -c %CUDA_SRC% -o %CUDA_BIN% --use-local-env --cl-version %CL_VERSION% -gencode=arch=compute_62,code=sm_62 --machine 64
nvcc -fatbin -c %CUDA_SRC% -o %CUDA_BIN% --use-local-env --cl-version %CL_VERSION% -gencode=arch=compute_62,code=sm_62 --machine 64
REM done
nvcc -fatbin -c %CUDA_SRC% -o %CUDA_BIN% ^
--use-local-env --cl-version %CL_VERSION% --machine 64 ^
-gencode=arch=compute_50,code=sm_50 ^
-gencode=arch=compute_52,code=sm_52 ^
-gencode=arch=compute_53,code=sm_53 ^
-gencode=arch=compute_60,code=sm_60 ^
-gencode=arch=compute_61,code=sm_61 ^
-gencode=arch=compute_62,code=sm_62

ENDLOCAL
SET ERRORLEVEL=0
5 changes: 3 additions & 2 deletions src/win32/PY27_MINGW_BUILD.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ fi

if [ "${DO_CUDA}" == "1" ]; then
echo "* Building CUDA kernels"
cmd.exe //c "win32\\BUILD_CUDA_KERNEL" BGRA_to_NV12
cmd.exe //c "win32\\BUILD_CUDA_KERNEL" BGRA_to_YUV444
cmd.exe //c "win32\\BUILD_CUDA_KERNEL" BGRA_to_NV12 || exit 1
cmd.exe //c "win32\\BUILD_CUDA_KERNEL" BGRA_to_YUV444 || exit 1
echo
fi

echo "* Building Python 2.7 Cython modules"
Expand Down
8 changes: 6 additions & 2 deletions src/xpra/codecs/cuda_common/cuda_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,17 @@ def get_CUDA_function(device_id, function_name):
log("get_CUDA_function(%s, %s) cubin file=%s", device_id, function_name, cubin_file)
data = load_binary_file(cubin_file)
if not data:
log.error("failed to load CUDA bin file %s", cubin_file)
log.error("Error: failed to load CUDA bin file '%s'", cubin_file)
return None
log(" loaded %s bytes", len(data))
KERNELS[function_name] = data
#now load from cubin:
start = time.time()
mod = driver.module_from_buffer(data)
try:
mod = driver.module_from_buffer(data)
except Exception as e:
log.error("Error: failed to load module from buffer for '%s'", function_name)
return None
log("get_CUDA_function(%s, %s) module=%s", device_id, function_name, mod)
try:
CUDA_function = mod.get_function(function_name)
Expand Down
17 changes: 1 addition & 16 deletions src/xpra/codecs/nv_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
from xpra.log import Logger
log = Logger("encoder", "nvenc")
from xpra.os_util import WIN32
from xpra.util import pver, print_nested_dict, engs, envbool


Expand Down Expand Up @@ -53,21 +52,7 @@ def get_proc_driver_version():


def identify_nvidia_module_version():
if os.name!="posix":
if not WIN32:
log.warn("Warning: unable to identify the NVidia driver version on this platform")
return None
#try the nvapi call:
try:
from xpra.codecs.nvapi_version import get_driver_version #@UnresolvedImport
v = get_driver_version()
log("NVAPI get_driver_version()=%s", v)
except Exception as e:
log.warn("Warning: failed to get the driver version through NVAPI:")
log.warn(" %s", e)
v = []
else:
v = get_nvml_driver_version() or get_proc_driver_version()
v = get_nvml_driver_version() or get_proc_driver_version()
#only keep numeric values:
numver = []
try:
Expand Down
63 changes: 0 additions & 63 deletions src/xpra/codecs/nvapi_version.pyx

This file was deleted.

0 comments on commit 2cff3bd

Please sign in to comment.