Here's a simple test function that calls Rcpp::stop()
#include <Rcpp.h>
NumericVector dostop()
{
Rcpp::stop("foo");
NumericVector x(1);
return x;
}
With clang on OS X, this performs as expected:
> library(Rcpp)
> sourceCpp('stop.cpp')
> dostop()
Error in dostop() : foo
>
However, with g++ on Linux, this function crashes R:
> library(Rcpp)
> sourceCpp('stop.cpp')
> dostop()
*** glibc detected *** /share/apps/R/3.3.3/lib64/R/bin/exec/R: free(): invalid pointer: 0x0000000001c29ff8 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3407c75f4e]
/lib64/libc.so.6[0x3407c78cad]
/tmp/RtmpiUT8Xb/sourceCpp-x86_64-pc-linux-gnu-1.0.1/sourcecpp_7dc862cd8f07/sourceCpp_2.so(_Z31exception_to_condition_templateIN4Rcpp9exceptionEEP7SEXPRECRKT_b+0x1da)[0x7f6fab831287]
/tmp/RtmpiUT8Xb/sourceCpp-x86_64-pc-linux-gnu-1.0.1/sourcecpp_7dc862cd8f07/sourceCpp_2.so(_Z29rcpp_exception_to_r_conditionRKN4Rcpp9exceptionE+0x29)[0x7f6fab83073d]
/tmp/RtmpiUT8Xb/sourceCpp-x86_64-pc-linux-gnu-1.0.1/sourcecpp_7dc862cd8f07/sourceCpp_2.so(sourceCpp_1_dostop+0x27d)[0x7f6fab82dd02]
/share/apps/R/3.3.3/lib64/R/lib/libR.so(+0xdc4fe)[0x7f6fb4ea04fe]
(and many more lines of similar)
Here is the relevant sessionInfo:
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Workstation release 6.6 (Santiago)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Rcpp_1.0.1
Question 1: Should am I using Rcpp::stop() correctly? That is, should I expect to be able to call it and get an error message at the console like in the OS X case?
Question 2: If so, is there any workaround for the decidedly suboptimal behavior that I'm seeing on Linux/g++?
Brief answers:
Question 1
You are using Rcpp::stop() correctly. But your system is a few years, and several R releases behind, and we made several dozen (!!) Rcpp releases since it was current. That combination of stone-old R and compiler with current Rcpp is rare.
Question 2
Upgrade to current versions, or stick with the ancient ones we made when those R and g++ versions rules. Maybe try an Rcpp version 0.12.* or 0.13.*.
Example
On current OS and compiler versions:
> Rcpp::cppFunction('double doStop(NumericVector x) { stop("foo"); return x[1]; }')
> doStop(c(1.2, 3.4))
Error in doStop(c(1.2, 3.4)) : foo
>
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.10
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.3.3.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0 Rcpp_1.0.1
>
I ran into this issue recently under centos 7.3 and R 3.6. You are probably using a version of gcc >= 5.1 together with the associated libstdc++ while your glibc version is <= 2.17.
In this context, C++11 code better be compiled using the -D_GLIBCXX_USE_CXX11_ABI=0 flag to work correctly.
You can add
CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0
in your ~/.R/Makevars file and reinstall Rcpp. I didn't noticed any issue after the change.
Related
I think this question is a duplicate: RcppEigen install failure on Ubuntu 20.04: warning: ignoring attributes on template argument ‘__m128’
However I don't think the solution proposed will work for me as I do not have root access to the machine. I am using R in a conda environment on Ubuntu 18 Bionic Beaver. Attempting to install RcppEigen gives a bunch of warnings (snippet of which are shown), then the make command abruptly fails:
../inst/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type {aka __vector(2) double}' [-Wignored-attributes]
../inst/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type {aka __vector(2) double}' [-Wignored-attributes]
make: *** [/home/4469722/miniconda3/envs/r_env/lib/R/etc/Makeconf:175: fastLm.o] Error 1
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/home/4473331/R/x86_64-conda_cos6-linux-gnu-library/3.6/RcppEigen’
Any help is appreciated. Here is my session info:
R version 3.6.1 (2019-07-05)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS/LAPACK: /home/4469722/miniconda3/envs/r_env/lib/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
I'm getting an error when attempting to compile Haskell tests using test-framework on Windows.
Steps to reproduce
Create a new library using Stack:
$ stack new repro simple-library
Then navigate into the repro directory and edit the repro.cabal file by adding test-framework to build-depends:
library
hs-source-dirs: src
exposed-modules: Lib
build-depends: base >= 4.7 && < 5,
test-framework
default-language: Haskell2010
Now attempt to compile the library:
$ stack build
Expected outcome
The code compiles
Actual outcome
Compilation fails with this error message:
$ stack build
WARNING: Ignoring mintty's bounds on Win32 (>=2.13.1); using Win32-2.6.2.1.
Reason: trusting snapshot over cabal file dependency information.
mintty > configure
mintty > Configuring mintty-0.1.3...
mintty > build
mintty > Preprocessing library for mintty-0.1.3..
mintty > Building library for mintty-0.1.3..
mintty > [1 of 1] Compiling System.Console.MinTTY
mintty >
mintty > src\System\Console\MinTTY.hs:31:1: error:
mintty > Could not find module `System.Console.MinTTY.Win32'
mintty > Use -v (or `:set -v` in ghci) to see a list of the files searched for.
mintty > |
mintty > 31 | import qualified System.Console.MinTTY.Win32 as Win32 (isMinTTY, isMinTTYHandle)
mintty > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mintty >
Progress 1/5
-- While building package mintty-0.1.3 (scroll up to its section to see the error) using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.7.exe --builddir=.stack-work\dist\274b403a build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
How do I resolve this error?
Environment
$ stack --version
Version 2.7.3, Git revision 7927a3aec32e2b2e5e4fb5be76d0d50eddcc197f x86_64 hpack-0.34.4
Windows
Edition Windows 10 Pro
Version 21H1
Installed on 14.09.2020
OS build 19043.1348
Experience Windows Feature Experience Pack 120.2212.3920.0
I assume, given when you posted this question, you are using LTS 18.17. Looking at that LTS, it uses mintty 0.1.3. Looking in mintty 0.1.3's cabal file shows a special flag that is enabled by default that means that System.Console.MinTTY.Win32 is not included. The comments in that cabal file say that that flag should be used when using Win32 2.13.1.0 or newer.
However, when I look at LTS 18's configuration in Stackage, I can see that it is using Win32 2.6.2.1, so that flag ought to be set to false for this package to work.
So let's check that in the Stackage build constraints. I see that another flag is being set, and it seems to be an old flag that is no longer used (looks like it was used in an older 0.1.2 version). This must be the problem.
The solution: manually set the flag in your stack.yaml:
flags:
mintty:
Win32-2-13-1: false
I am trying to build my own Rcpp package, it works pretty well in my local computer, now I am installing it into another computer, the following error pops up:
ERROR: dependency ‘RcppArmadillo’ is not available for package "my_package_name"
Below is some information about the environment (by sessionInfo()):
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3]
LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5]
LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7]
LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C
LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.3
In the DESCRIPTION file, I already have
Linking to: Rcpp, RcppArmadillo
One action I tried but still did not work is installing the development versions of BLAS and LAPACK as suggested in https://support.bioconductor.org/p/117905/
Is there anyone knows which causes this error? Thank you in advance!
I'm playing with a couple of projects that explicitly require pytorch == 1.0.0, but I have an old graphics card that only supports cuda 3.0 so I'm using the cpu, which is very slow, being the graphics card a dual gpu I decided to give a try and build pytorch from the sources with support for 3.0 (I have planned to update the pc but is not gonna happen anytime soon).
I am using docker to do the build, in particular I tried to modify an existing Dockerfile from build-pytorch, on the host system I am using debian/sid and there is cuda 10.2 cudnn 7.6 installed, I'm not sure if I can downgrade cuda, and I don't know if the versions in the container must be exactly the same as the host (like for nvidia drivers).
Gist of the modified Dockerfile
The first thing I noticed when updating the versions is that package cuda-cublas-dev-10-2 was not found, the latest version was 10-0,
CUBLAS packaging changed in CUDA 10.1 to be outside of the toolkit installation path
If I install cublas version 10-0 or if I don't install it obviously no header files are found (error below), if I install the recommended libcublas-dev version the build continues for a while, with some warnings (below) , but then it stops with the error below.
I searched for the error online but I did not find anything specific, if I understand correctly there is a function declared more than once and when it is called the choice is ambiguous, but I have not yet investigated looking at the sources.
I would like to know if anyone has run into this error before and knows how to fix it.
libcublas-dev installed error:
[ 67%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/sparse/cuda/caffe2_gpu_generated_SparseCUDABlas.cu.o
/pytorch/aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cu(58): error: more than one instance of function "at::native::sparse::cuda::cusparseGetErrorString" matches the argument list:
function "cusparseGetErrorString(cusparseStatus_t)"
function "at::native::sparse::cuda::cusparseGetErrorString(cusparseStatus_t)"
argument types are: (cusparseStatus_t)
1 error detected in the compilation of "/tmp/tmpxft_00004ccc_00000000-6_SparseCUDABlas.cpp1.ii".
CMake Error at caffe2_gpu_generated_SparseCUDABlas.cu.o.Release.cmake:279 (message):
Error generating file
/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/sparse/cuda/./caffe2_gpu_generated_SparseCUDABlas.cu.o
caffe2/CMakeFiles/caffe2_gpu.dir/build.make:1260: recipe for target 'caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/ATen/native/sparse/cuda/caffe2_gpu_generated_SparseCUDABlas.cu.o' failed
warnings:
ptxas warning : Too big maxrregcount value specified 96, will be ignored
missing header error:
Scanning dependencies of target caffe2_pybind11_state
[ 59%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state.cc.o
In file included from /pytorch/aten/src/THC/THC.h:4:0,
from /pytorch/torch/lib/THD/../THD/base/TensorDescriptor.h:6,
from /pytorch/torch/lib/THD/../THD/base/TensorDescriptor.hpp:6,
from /pytorch/torch/lib/THD/../THD/THD.h:14,
from /pytorch/torch/lib/THD/base/DataChannelRequest.h:3,
from /pytorch/torch/lib/THD/base/DataChannelRequest.hpp:6,
from /pytorch/torch/lib/THD/base/DataChannelRequest.cpp:1:
/pytorch/build/caffe2/aten/src/THC/THCGeneral.h:17:23: fatal error: cublas_v2.h: No such file or directory
compilation terminated.
make[2]: *** [caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/DataChannelRequest.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Apparently the problem was that both libcusparse and aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cu implement cusparseGetErrorString() and for version >= 10.2 the one in the library should be used.
--- aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cu.orig 2020-11-16 12:13:17.680023134 +0000
+++ aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cu 2020-11-16 12:13:45.158407583 +0000
## -9,7 +9,7 ##
namespace at { namespace native { namespace sparse { namespace cuda {
-
+#if 0
std::string cusparseGetErrorString(cusparseStatus_t status) {
switch(status)
{
## -51,6 +51,7 ##
}
}
}
+#endif
inline void CUSPARSE_CHECK(cusparseStatus_t status)
{
I haven't tried yet if it works at runtime but the build is successful.
I'm trying to install Haskelly extension for vs studio code by following the steps here.
rajkumar#linux-2278:~> stack install intero QuickCheck stack-run
stack-run-0.1.1.4: configure
stack-run-0.1.1.4: build
-- While building package stack-run-0.1.1.4 using:
/home/rajkumar/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /home/rajkumar/.stack/global-project/.stack-work/logs/stack-run-0.1.1.4.log
Configuring stack-run-0.1.1.4...
Preprocessing executable 'stack-run' for stack-run-0.1.1.4..
Building executable 'stack-run' for stack-run-0.1.1.4..
/tmp/stack30563/stack-run-0.1.1.4/unix/System/Console/Questioner.hs:4:14: warning:
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
|
4 | {-# LANGUAGE OverlappingInstances #-}
| ^^^^^^^^^^^^^^^^^^^^
[1 of 5] Compiling System.Console.Questioner.Autocomplete ( unix/System/Console/Questioner/Autocomplete.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner/Autocomplete.o )
[2 of 5] Compiling System.Console.Questioner.Util ( unix/System/Console/Questioner/Util.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner/Util.o )
[3 of 5] Compiling System.Console.Questioner.ProgressIndicators ( unix/System/Console/Questioner/ProgressIndicators.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner/ProgressIndicators.o )
[4 of 5] Compiling System.Console.Questioner ( unix/System/Console/Questioner.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner.o )
[5 of 5] Compiling Main ( src/Main.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/stack-run/stack-run-tmp/Main.o )
/tmp/stack30563/stack-run-0.1.1.4/src/Main.hs:18:1: error:
Could not find module ‘Distribution.PackageDescription.Parse’
Perhaps you meant
Distribution.PackageDescription.Parsec (needs flag -package-key Cabal-2.4.0.1)
Distribution.PackageDescription.Parsec (from Cabal-2.4.1.0)
Distribution.PackageDescription.Check (needs flag -package-key Cabal-2.4.0.1)
Use -v to see a list of the files searched for.
|
18 | import Distribution.PackageDescription.Parse
Below is the contents of /home/rajkumar/.stack/global-project/stack.yaml -
packages: []
resolver: lts-13.21
allow-newer: true
extra-deps:
- conduit-1.2.13.1
- conduit-extra-1.1.17
- resourcet-1.1.11
- streaming-commons-0.1.19
cabal version -
$ cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
stack version -
$ stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
Below are the OpenSuse OS details -
rajkumar#linux-2278:~> lsb_release -a
LSB Version: core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0-amd64:desktop-4.0-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch
Distributor ID: openSUSE
Description: openSUSE Leap 15.0
Release: 15.0
Codename: n/a
This also happens in Fedora 30 OS -
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: Fedora
Description: Fedora release 30 (Thirty)
Release: 30
Codename: Thirty
I don't know how to resolve this issue. Any idea would be helpful.
You are running Cabal version 2.4 and package Distribution.PackageDescription.Parse was removed in Cabal 2.2. See Cabal issue tracker.
Consider using Distribution.PackageDescription.Parsec instead. They are using that in obelisk project.
As per the doco for Haskelly, if you run into issues, refer to
https://github.com/yamadapc/stack-run/issues/17#issuecomment-427545735
Essentially, modify your stack.yml, then run individually:
stack build
stack build intero
stack install QuickCheck
stack --stack-yaml ~/.stack/global-project/stack-cabal-1.24.yaml install stack-run