[bug / patch ]patch for glibc 2.26 to avoid errors in compiling with CUDA(NVCC)

Bug #1717257 reported by DSUZUKI
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
gcc-7 (Ubuntu)
Fix Released
Undecided
Adam Conrad
glibc (Ubuntu)
Fix Released
Undecided
Adam Conrad

Bug Description

DistroRelease: Ubuntu 17.10 (Proposed)
Package: glibc 2.26-0ubuntu1
Architecture: amd64
extrapackage (not incl. in UBUNTU) NVIDIA-DRIVER, CUDA
-------------------------------------------------------------------------------

Here is another proposal regarding bug report I posted (but in reject).
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1716816

I reported that glibc 2.26-0ubuntu1 ( adopted in Artful-proposed on Sep 5.) causes compilation error by using NVIDIA's CUDA8.0 and 9.0RC.

Under glibc 2.24, they work.

It maybe comes from glibc226's new feature, i.e. "128-bit floating point as defined by ISO/IEC/IEEE 60559:2011 (IEEE 754-2008) and ISO/IEC TS 18661-3:2015" . (Evidence Scripted at bottom)

I proposed the patch to

  /usr/include/x86_64-linux-gnu/bits/floatn.h

which lets NVCC (CUDA's compiler) avoid __float128 (NVCC does support neither 8.0 nor 9.0).

So can the patch be merged to glibc2.25 be adopted in Arful or later?

-------------------------------------------------------------------------------------
*** floatn.h-dist 2017-09-04 16:34:21.000000000 +0900
--- floatn.h 2017-09-14 21:46:15.334033614 +0900
***************
*** 28,34 ****
     support, for x86_64 and x86. */
  #if (defined __x86_64__ \
       ? __GNUC_PREREQ (4, 3) \
! : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
  # define __HAVE_FLOAT128 1
  #else
  # define __HAVE_FLOAT128 0
--- 28,35 ----
     support, for x86_64 and x86. */
  #if (defined __x86_64__ \
       ? __GNUC_PREREQ (4, 3) \
! : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \
! && !defined(__CUDACC__)
  # define __HAVE_FLOAT128 1
  #else
  # define __HAVE_FLOAT128 0
-------------------------------------------------------------------------------------

(evidence)
----------
1. Here is part of message during compiing Tensorflow with CUDA on UBUNTU17.10 beta with proposed-components. .
--------------
typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
                         ^
INFO: From Compiling external/nccl_archive/src/broadcast.cu.cc:
/usr/include/x86_64-linux-gnu/bits/floatn.h(61): error: invalid argument to attribute "__mode__"

/usr/include/x86_64-linux-gnu/bits/floatn.h(73): error: identifier "__float128" is undefined
--------------

2. Forums in INVIDIA
where issues the problems around glibc.2.26

NVIDIA
https://devtalk.nvidia.com/default/topic/1023776/cuda-programming-and-performance/-request-add-nvcc-compatibility-with-glibc-2-26/

3. THis bug has already discussed in Arch linux and the patch (tas same ) proposed
https://www.reddit.com/r/archlinux/comments/6zrmn1/torch_on_arch/

DSUZUKI (gdaisuzu)
description: updated
DSUZUKI (gdaisuzu)
description: updated
description: updated
description: updated
DSUZUKI (gdaisuzu)
summary: - proposal of patch to avoid erros in compiping NVCC
+ proposal of patch for glibc to avoid erros in compiping NVCC
DSUZUKI (gdaisuzu)
summary: - proposal of patch for glibc to avoid erros in compiping NVCC
+ [bug / patch ]patch for glibc 2.26 to avoid errors in compiling with
+ CUDA(NVCC)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in glibc (Ubuntu):
status: New → Confirmed
Revision history for this message
Steffen Röcker (sroecker) wrote :

I can confirm the compilation problems with CUDA8.
Perhaps the correct package should be clang-3.8 since it's used by nvcc and is incompatible with libstdc++-7-dev.

See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=871011

Revision history for this message
Steffen Röcker (sroecker) wrote :

I've found several bug reports and am sure that the problem stems from clang-3.8 being built with libstdc++-7-dev and not properly supporting __float128
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=678033

Google patched gcc by hiding _GLIBCXX_USE_FLOAT128 from clang:
https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00672.html

There also seems to be a simple typedef workaround:
https://stackoverflow.com/questions/13525774/clang-and-float128-bug-error

I had to patch /usr/include/c++/7.2.0/bits/std_abs.h
in order to compile cupy from source with CUDA8.
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__)

Adam Conrad (adconrad)
Changed in glibc (Ubuntu):
assignee: nobody → Adam Conrad (adconrad)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in llvm-toolchain-3.8 (Ubuntu):
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package glibc - 2.26-0ubuntu2

---------------
glibc (2.26-0ubuntu2) artful; urgency=medium

  * Cherry-pick some changes from Debian git for a few pending Ubuntu bugfixes:
    - Update to master and drop redundant submitted-tst-tlsopt-powerpc.diff.
    - debian/patches/any/local-cudacc-float128.diff: Local patch to prevent
      defining __HAVE_FLOAT128 on NVIDIA's CUDA compilers (LP: #1717257)
    - debian/patches/arm/git-arm64-memcmp.diff: Backport optimized memcmp
      for AArch64, improving performance from 25% to 500% (LP: #1720832)
    - debian/patches/amd64/git-x86_64-search.diff: Backport upstream commit
      to put x86_64 back in the search path, like in 2.25 (LP: #1718928)
    - debian/rules.d/debhelper.mk: Filter python hooks in stage1 (LP: #1715366)

 -- Adam Conrad <email address hidden> Wed, 11 Oct 2017 14:21:40 -0600

Changed in glibc (Ubuntu):
status: Confirmed → Fix Released
Adam Conrad (adconrad)
Changed in gcc-7 (Ubuntu):
assignee: nobody → Adam Conrad (adconrad)
Changed in llvm-toolchain-3.8 (Ubuntu):
status: Confirmed → Invalid
Adam Conrad (adconrad)
Changed in gcc-7 (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-7 - 7.2.0-8ubuntu3

---------------
gcc-7 (7.2.0-8ubuntu3) artful; urgency=medium

  * debian/patches/cuda-float128.diff: Mask __float128 from CUDA (LP: #1717257)

 -- Adam Conrad <email address hidden> Sat, 14 Oct 2017 14:35:40 -0600

Changed in gcc-7 (Ubuntu):
status: Fix Committed → Fix Released
Mathew Hodson (mhodson)
no longer affects: llvm-toolchain-3.8 (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.