简体   繁体   English

Qt:与Qt OSX优胜美地的CUDA“sed:非法选项 - r”错误

[英]Qt: CUDA with Qt OSX Yosemite “sed: illegal option — r” error

I am building a simple app with Qt creator, in which I want to utilise CPU and GPU computation to complete a task and then compare the execution time in m/s. 我正在使用Qt创建器构建一个简单的应用程序,其中我想利用CPU和GPU计算来完成任务,然后以m / s比较执行时间。

I have read numerous articles and have concluded that I need to separate NVCC and GCC compilers from one another to avoid conflict. 我已阅读了大量文章并得出结论,我需要将NVCC和GCC编译器彼此分开以避免冲突。 I followed this tutorial , making tweaks for my system, however when I compile I get a strange error: 我按照本教程 ,对我的系统进行了调整,但是当我编译时出现了一个奇怪的错误:

sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
make: *** [gaussian_cuda.o] Error 1
14:42:46: The process "/usr/bin/make" exited with code 2.

The error is obviously being thrown from this line in my .pro configuration: .pro配置中,这行显然是错误的:

2>&1 | sed -r \"s/\\(([0-9]+)\\)/:\\1/g\" 1>&2

I don't understand why this is an illegal operation, and when I try to remove this line my code breaks completely. 我不明白为什么这是一个非法操作,当我尝试删除此行时,我的代码完全中断。

Why is r an illegal operation? 为什么r是非法操作?

EDIT Complete config code: 编辑完整的配置代码:

QT       += core gui
QT       += multimedia
QT       += multimediawidgets
QT       += concurrent

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = WebcamFilter
TEMPLATE = app

SOURCES += main.cpp\
           mainwindow.cpp \
           camerafeed.cpp \

HEADERS  += mainwindow.h \
            camerafeed.h

FORMS    += mainwindow.ui

# CUDA Resources
CUDA_SOURCES += gaussian.cu
CUDA_DIR      = /usr/local/cuda
# Path to header and lib files
INCLUDEPATH  += $$CUDA_DIR/include
QMAKE_LIBDIR += $$CUDA_DIR/lib
# Libs used for source code
LIBS         += -lcudart -lcuda
# GPU Architecture
CUDA_ARCH     = sm_20
# Custom flags for nvcc
NVCCFLAGS     = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
# Prepare extra compiler configuration
CUDA_INC      = $$join(INCLUDEPATH,' -I','-I',' ')
cuda.commands = $$CUDA_DIR/bin/nvcc -m64 -O3 -arch=$$CUDA_ARCH -c $$NVCCFLAGS \
                $$CUDA_INC $$LIBS  ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} \
                2>&1 | sed -r \"s/\\(([0-9]+)\\)/:\\1/g\" 1>&2
cuda.dependency_type = TYPE_C
cuda.depend_command  = $$CUDA_DIR/bin/nvcc -O3 -M $$CUDA_INC $$NVCCFLAGS   ${QMAKE_FILE_NAME}

cuda.input = CUDA_SOURCES
cuda.output = ${OBJECTS_DIR}${QMAKE_FILE_BASE}_cuda.o
# Tell Qt that we want add more stuff to the Makefile
QMAKE_EXTRA_COMPILERS += cuda

As Park Young-Bae suggested, Mac sed is not equivalent to GNU sed and therefore the flag: 正如Park Young-Bae所说,Mac sed不等同于GNU sed ,因此标志:

2>&1 | sed -r \"s/\\(([0-9]+)\\)/:\\1/g\" 1>&2

had to be amended to: 必须修改为:

2>&1 | sed -E \"s/\\(([0-9]+)\\)/:\\1/g\" 1>&2

This fixed the issue. 这解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM