Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Compiling CUDA files with Qt 5.12
Forum Updated to NodeBB v4.3 + New Features

Compiling CUDA files with Qt 5.12

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
13 Posts 5 Posters 6.0k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ailurus
    wrote on last edited by
    #3

    I'm on (Arch) Linux, 64-bit.

    kshegunovK 1 Reply Last reply
    0
    • A Ailurus

      I'm on (Arch) Linux, 64-bit.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #4

      I don't know why it tries to generate that dependency, but as a long shot can you try without changing the objects file name, i.e.:

      cuda.output = ${QMAKE_FILE_BASE}.o
      

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        Tested it on macOS and it worked correctly.

        Can you show the rest of your .pro file ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • A Offline
          A Offline
          Ailurus
          wrote on last edited by
          #6

          Thanks guys for looking into it. @kshegunov, in that case the error changes to

          :-1: error: No rule to make target ':', needed by 'CodeCUDA.o'.  Stop.
          

          Part of the Makefile then looks like this —

          		../OpenGL/CodeCUDA.cu \
          		\: \
          		../OpenGL/CodeCUDA.cu \
          		/ \
          		/usr/include/stdc-predef.h \
          		/ \
          

          This is the entire .pro file —

          #-------------------------------------------------
          #
          # Project created by QtCreator 2019-01-07T11:13:21
          #
          #-------------------------------------------------
          
          QT += core gui
          
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          
          TARGET = TemplateShowMeshOpenGL
          TEMPLATE = app
          
          # The following define makes your compiler emit warnings if you use
          # any feature of Qt which has been marked as deprecated (the exact warnings
          # depend on your compiler). Please consult the documentation of the
          # deprecated API in order to know how to port your code away from it.
          DEFINES += QT_DEPRECATED_WARNINGS
          
          # You can also make your code fail to compile if you use deprecated APIs.
          # In order to do so, uncomment the following line.
          # You can also select to disable deprecated APIs only up to a certain version of Qt.
          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
          
          CONFIG += c++11
          
          SOURCES += \
                  main.cpp \
                  mainwindow.cpp \
              mainview.cpp
          
          HEADERS += \
                  mainwindow.h \
              mainview.h
          
          FORMS += \
                  mainwindow.ui
          
          # File(s) containing my CUDA code
          CUDA_SOURCES = CodeCUDA.cu \
                       KernelVBO.cu
          
          # Location of CUDA on my system (Arch Linux)
          CUDA_DIR = /opt/cuda
          
          INCLUDEPATH += $$CUDA_DIR/include
          LIBS += -L$$CUDA_DIR/lib64 -lcuda -lcudart
          
          # Compute capability of my GPU
          CUDA_ARCH = sm_30
          
          cuda.input = CUDA_SOURCES
          cuda.output = ${QMAKE_FILE_BASE}_cuda.o
          cuda.commands = $$CUDA_DIR/bin/nvcc -c -arch=$$CUDA_ARCH -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
          cuda.dependency_type = TYPE_C
          cuda.depend_command = $$CUDA_DIR/bin/nvcc -M ${QMAKE_FILE_NAME}
          
          QMAKE_EXTRA_COMPILERS += cuda
          
          # Default rules for deployment.
          qnx: target.path = /tmp/$${TARGET}/bin
          else: unix:!android: target.path = /opt/$${TARGET}/bin
          !isEmpty(target.path): INSTALLS += target
          
          RESOURCES += \
              resources.qrc
          

          I'm using Qt Creator 4.8.1, QMake version 3.1, and Qt version 5.12.0.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @Ailurus said in Compiling CUDA files with Qt 5.12:

            CUDA_SOURCES

            What if you try with:

            CUDA_SOURCES += \
                         $$PWD/CodeCUDA.cu \
                         $$PWD/KernelVBO.cu
            

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Ailurus
              wrote on last edited by
              #8

              Unfortunately that does not make a difference. Hmm, could it be a setting somewhere in Build Settings? Effective qmake call is set to

              /usr/bin/qmake /home/pieter/Dropbox/CUDA/OpenGL/TemplateShowMeshOpenGL.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug && /usr/bin/make qmake_all
              

              Manually changing the Makefile is not a big issue, at this point I'm just curious why it is generated like it is.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                That version of qmake is the one from your distribution and likely not the one from your 5.12 installation.

                Use the full path to it to ensure the correct one is used.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • A Offline
                  A Offline
                  Ailurus
                  wrote on last edited by
                  #10

                  Hmm, it's the only qmake I have on my machine. Info —

                  $ which qmake
                  /usr/bin/qmake
                  $ /usr/bin/qmake -v
                  QMake version 3.1
                  Using Qt version 5.12.0 in /usr/lib
                  
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    Good to know.

                    In that case, can you try with the pre-built version ? Just to compare the output.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • BrandonLB Offline
                      BrandonLB Offline
                      BrandonL
                      wrote on last edited by
                      #12

                      This is definitely a problem when upgrading from an older version of qmake to qmake 3.1 which is part of Qt 5.12.3.
                      For some reason qmake 3.1 parses the output of a compile depend_command differently than before, which breaks existing .pro files that use a custom compiler for CUDA. Qmake ends up constructing a dependency list that looks like this:

                      ...
                      cuda/foo.cuh \
                      cuda/foo.cu \
                      buildDir/MyCudaLib.o \ 
                      \: \               <--------- THIS IS WRONG
                      cuda/bar.cu \
                      / \
                      /usr/local/cuda/include/cuda_runtime.h \
                      ...
                      

                      The solution is to pipe the output of nvcc to:

                      sed \"s/^.*: //\"
                      

                      to filter out the garbage, ie:

                      cuda.depend_command = $$CUDA_DIR/bin/nvcc -g -M $$CUDA_INC $$NVCCFLAGS ${QMAKE_FILE_NAME} | sed \"s/^.*: //\"
                      
                      1 Reply Last reply
                      1
                      • K Offline
                        K Offline
                        kalyan ch
                        wrote on last edited by
                        #13

                        remove this line->cuda.depend_command = $$CUDA_DIR/bin/nvcc -M ${QMAKE_FILE_NAME}

                        1 Reply Last reply
                        0
                        • Pl45m4P Pl45m4 referenced this topic on

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved