Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media-libs/opensubdiv: use cuda eclass #22852

Closed
wants to merge 1 commit into from

Conversation

Fat-Zer
Copy link
Contributor

@Fat-Zer Fat-Zer commented Nov 6, 2021

  • Utilize cuda eclass and let it handle gcc selection instead of forcing
    an outdated version.
  • Add a fix to provide sane defaults when compiling against a recent
    enough CUDA versions.
  • Add an option to pass user-specified NVCCFLAGS and prevent cmake from
    overriding them.

Closes: https://bugs.gentoo.org/744517
Closes: https://bugs.gentoo.org/751382
Signed-off-by: Alexander Golubev fatzer2@gmail.com

* Utilize cuda eclass and let it handle gcc selection instead of forcing
  an outdated version.
* Add a fix to provide sane defaults when compiling against a recent
  enough CUDA versions.
* Add an option to pass user-specified NVCCFLAGS and prevent cmake from
  overriding them.

Closes: https://bugs.gentoo.org/744517
Closes: https://bugs.gentoo.org/751382
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
@gentoo-bot
Copy link

Pull Request assignment

Submitter: @Fat-Zer
Areas affected: ebuilds
Packages affected: media-libs/opensubdiv

media-libs/opensubdiv: @redchillipadi, @gentoo/proxy-maint

Linked bugs

Bugs linked: 744517, 751382


In order to force reassignment and/or bug reference scan, please append [please reassign] to the pull request title.

Docs: Code of ConductCopyright policy (expl.) ● DevmanualGitHub PRsProxy-maint guide

@gentoo-bot gentoo-bot added assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR. labels Nov 7, 2021
@gentoo-repo-qa-bot
Copy link
Collaborator

Pull request CI report

Report generated at: 2021-11-07 00:10 UTC
Newest commit scanned: 441c119
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/6f37c1372d/output.html

Copy link
Member

@juippis juippis left a comment

Choose a reason for hiding this comment

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

+cuda seems to fail for me, not sure if it's because I don't have an nvidia card. Please see:
https://cpy.pt/yUHZ4rq8?raw
("exit_code": 1, means failure)

#$ "/usr/x86_64-pc-linux-gnu/gcc-bin/11.2.0"/gcc -D__CUDA_ARCH__=350 -D__CUDA_ARCH_LIST__=350 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ "-march=native" "-O2" "-pipe" "-frecord- gcc-switches" -march=native -O2 -pipe -frecord-gcc-switches -fPIC -O2 -I"/opt/cuda/include" -I"/var/tmp/portage/media-libs/opensubdiv-3.4.4-r2/work/OpenSubdiv-3_4_4/opensubdiv" -I"/usr/include" -I"/ var/tmp/portage/media-libs/opensubdiv-3.4.4-r2/work/OpenSubdiv-3_4_4/glLoader" "-I/opt/cuda/bin/../ targets/x86_64-linux/include" -D "OPENSUBDIV_VERSION_STRING="3.4.4"" -D "OPENSUBDIV_HAS_OPENGL" -D "OSD_USES_INTERNAL_GLAPILOADER" -D "GLFW_VERSION_3" -D "OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK" -D "OPENSUBDIV_HAS_GLSL_COMPUTE" -D "OPENSUBDIV_HAS_CUDA" -D "CUDA_ENABLE_DEPRECATED=0" -D "NVCC" -D__CUDACC_VER_MAJOR__=11 -D__CUDACC_VER_MINOR__=5 - D__CUDACC_VER_BUILD__=50 -D__CUDA_API_VER_MAJOR__=11 -D__CUDA_API_VER_MINOR__=5 - D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -include "cuda_runtime.h" -m64 "/var/tmp/portage/media-libs/ opensubdiv-3.4.4-r2/work/OpenSubdiv-3_4_4/opensubdiv/osd/cudaKernel.cu" -o "/var/tmp/portage/media- libs/opensubdiv-3.4.4-r2/temp/tmpxft_0000016c_00000000-7_cudaKernel.cpp1.ii"
#$ cicc --c++17 --gnu_version=110200 --display_error_number --orig_src_file_name "/var/tmp/portage/ media-libs/opensubdiv-3.4.4-r2/work/OpenSubdiv-3_4_4/opensubdiv/osd/cudaKernel.cu" -- orig_src_path_name "/var/tmp/portage/media-libs/opensubdiv-3.4.4-r2/work/OpenSubdiv-3_4_4/ opensubdiv/osd/cudaKernel.cu" --allow_managed -arch compute_35 -m64 --no-version-ident -ftz=0 - prec_div=1 -prec_sqrt=1 -fmad=1 --include_file_name "tmpxft_0000016c_00000000-3_cudaKernel.fatbin. c" -tused --gen_module_id_file --module_id_file_name "/var/tmp/portage/media-libs/opensubdiv-3.4.4- r2/temp/tmpxft_0000016c_00000000-4_cudaKernel.module_id" --gen_c_file_name "/var/tmp/portage/media- libs/opensubdiv-3.4.4-r2/temp/tmpxft_0000016c_00000000-6_cudaKernel.cudafe1.c" --stub_file_name "/ var/tmp/portage/media-libs/opensubdiv-3.4.4-r2/temp/tmpxft_0000016c_00000000-6_cudaKernel.cudafe1. stub.c" --gen_device_file_name "/var/tmp/portage/media-libs/opensubdiv-3.4.4-r2/temp/ tmpxft_0000016c_00000000-6_cudaKernel.cudafe1.gpu" "/var/tmp/portage/media-libs/opensubdiv-3.4.4- r2/temp/tmpxft_0000016c_00000000-7_cudaKernel.cpp1.ii" -o "/var/tmp/portage/media-libs/opensubdiv-3.4.4-r2/temp/tmpxft_0000016c_00000000-6_cudaKernel.ptx"
/usr/include/stdio.h(183): error: attribute "malloc" does not take arguments

@Fat-Zer
Copy link
Contributor Author

Fat-Zer commented Nov 18, 2021

@juippis, hmmm... I can't reproduce it, could you share your emerge --info, the full build log, the environment and the version/USEs of dev-util/nvidia-cuda-toolkit?

PS: I haven't tried to build it on a system without an nvidia GPU, but it shouldn't fail...

@juippis
Copy link
Member

juippis commented Nov 18, 2021

@Fat-Zer thanks for looking into it!
Log here:
https://dev.gentoo.org/~juippis/logs/opensubdiv-3.4.4-r2_20211118-110645.log

# emerge --info
Portage 3.0.28 (python 3.10.0-final-0, default/linux/amd64/17.1, gcc-11.2.0, glibc-2.34-r2, 5.14.0-pf7 x86_64)
=================================================================
System uname: Linux-5.14.0-pf7-x86_64-AMD_Ryzen_7_3700X_8-Core_Processor-with-glibc2.34
KiB Mem:    32797012 total,  26307004 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 18 Nov 2021 08:51:40 +0000
Head commit of repository gentoo: 9e23642bc21973f57ece41a40edb7cb779cced9d

sh bash 5.1_p12
ld GNU ld (Gentoo 2.37_p1 p1) 2.37
app-shells/bash:          5.1_p12::gentoo
dev-lang/python:          3.8.12_p1::gentoo, 3.9.9::gentoo, 3.10.0_p1::gentoo
dev-util/cmake:           3.21.4::gentoo
sys-apps/baselayout:      2.8::gentoo
sys-apps/openrc:          0.44.8::gentoo
sys-apps/sandbox:         2.29::gentoo
sys-devel/binutils:       2.37_p1-r1::gentoo
sys-devel/gcc:            11.2.0::gentoo
sys-devel/gcc-config:     2.5::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.15::gentoo (virtual/os-headers)
sys-libs/glibc:           2.34-r2::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://anongit.gentoo.org/git/repo/sync/gentoo.git
    priority: -1000

localhost
    location: /root/localhost
    masters: gentoo

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--autounmask=y --autounmask-continue --autounmask-use=y --autounmask-write --buildpkg-exclude virtual --buildpkg-exclude acct-* --buildpkg-exclude sys-kernel --nospinner --jobs=8 --usepkg"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="https://distfiles.gentoo.org"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS=" en en_US en-US fi sv "
MAKEOPTS="-j16 -l10"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 bzip2 cli crypt dbus dri elogind fortran gdbm iconv ipv6 libglvnd libtirpc multilib ncurses nptl openmp openrc pam pcre readline seccomp split-usr ssl udev unicode xattr zlib" ABI_X86="64 32" ADA_TARGET="gnat_2019" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" L10N="en en_US en-US fi sv" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="AMDGPU BPF" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="pypy3 python3_8 python3_9 python3_10" RUBY_TARGETS="ruby26 ruby27" USERLAND="GNU" VIDEO_CARDS="amdgpu radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS

@Fat-Zer
Copy link
Contributor Author

Fat-Zer commented Nov 18, 2021

Ok... looks like it's a CUDA issue caused by combination of glibc-2.34 and gcc-11+. The NVidia promised to fix it with the next minor CUDA release. That explains why I couldn't reproduce it with glibc-2.33.

If it's so, I believe it shouldn't be touched in the opensubdiv ebuild. It can be either ignored (in hope for a sooner CUDA release) or mitigated in the cuda eclass/ebuild (if several other packages are affected).

It probably could be worked around by emerging sys-devel/gcc:10 or 9 and adding NVCCFLAGS="--compiler-bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/10.3.0/" to make.conf. As an alternative it plausibly could also be worked around by downgrading dev-util/nvidia-cuda-toolkit to 10.x (which will pool in sys-devel/gcc:9).

Though, I need a bit more testing to insure it's the issue and that the workarounds work. I suspect other packages that precompile CUDA kernels would be affected as well. The good candidate is media-gfx/blender. But I would need some time to test those assumptions...

Copy link
Member

@juippis juippis left a comment

Choose a reason for hiding this comment

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

@ionenwks ^ would you have an idea to the nvidia related things?

Somehow if we know stuff is broken, we should try to workaround then. I'm kind of uncomfortable merging this before we know what the root cause is.

Let me know what I can test, with my amdgpu. If either of tell me everything Just Works with nvidia, I'll believe you.

Copy link
Contributor

@ionenwks ionenwks left a comment

Choose a reason for hiding this comment

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

@juippis fwiw this package's IUSE=cuda been in a terrible state for a while either way, unlikely anyone been building it lately without looking up workarounds. Although being tossed a new -r2 to build that is known-failing also isn't that great :( No strong feeling about it but waiting for nvidia's fix to merge could make sense (do what you think is best).

One issue is that suggesting to use gcc10 as a workaround seem difficult, can't pass a new --compiler-bindir given seems it always overrides with latest compatible gcc.

But clang:13 + glibc-2.34 works even though the eclass doesn't consider it 👀 (cuda wants clang:12 that I didn't have around, so used NVCCFLAGS="-arch sm_61 -allow-unsupported-compiler" though)

Not that I tested runtime, I never used blender so I wouldn't know what to check (I don't really use/know cuda much either).

That aside, haven't looked that closely but PR has my approval. In case forgot it existed, it's an improved version of the old unmerged #18663. I'm liking using NVCCFLAGS for arch a lot better and using cuda eclass sounds better too.

@ionenwks
Copy link
Contributor

ionenwks commented Nov 21, 2021

Though, I need a bit more testing to insure it's the issue and that the workarounds work. I suspect other packages that precompile CUDA kernels would be affected as well. The good candidate is media-gfx/blender. But I would need some time to test those assumptions...

Don't need to go far to test (that's from cuda's tutorial, not that it actually prints hello world):

$ cat > test.cu <<-EOF
#include <stdio.h>

__global__ void cuda_hello() {
    printf("Hello World from GPU!\n");
}

int main() {
    cuda_hello<<<1,1>>>();
    return 0;
}
EOF
$ nvcc -o test test.cu
/usr/include/stdio.h(183): error: attribute "__malloc__" does not take arguments
$ nvcc --allow-unsupported-compiler --compiler-bindir /usr/lib/llvm/13/bin/clang -o test test.cu
(works)

Edit: like nvidia's thread, further shows that it's entirely unrelated to opensubdiv anyhow.

@juippis
Copy link
Member

juippis commented Nov 21, 2021

but waiting for nvidia's fix to merge could make sense

any ETA? :)

@ionenwks
Copy link
Contributor

ionenwks commented Nov 21, 2021

but waiting for nvidia's fix to merge could make sense

any ETA? :)

Nope, it's the usual nvidia says "fixed internally" and then we wait for a new release which can be tomorrow or a month+, unfortunately I too don't have access to nvidia's internal-only bug tracker for updates.

Edit: might add that they never answer if someone asks for ETA

@ionenwks
Copy link
Contributor

Well, it didn't take too long after all: see commit fb1cbae

@juippis
Copy link
Member

juippis commented Nov 27, 2021

^ This was totally pressured by us! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR.
Projects
None yet
5 participants