You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to replicate the PCA example in docs with the following code:
import pycuda.autoinit
import pycuda.gpuarray as gpuarray
import numpy as np
import skcuda.linalg as linalg
from skcuda.linalg import PCA as cuPCA
pca = cuPCA(n_components=4) # map the data to 4 dimensions
X = np.random.rand(1000,100) # 1000 samples of 100-dimensional data vectors
X_gpu = gpuarray.GPUArray((1000,100), np.float64) # note that order="F" or a transpose is necessary. fit_transform requires row-major matrices, and column-major is the default
X_gpu.set(X) # copy data to gpu
T_gpu = pca.fit_transform(X_gpu) # calculate the principal components
linalg.dot(T_gpu[:,0], T_gpu[:,1]) # show that the resulting eigenvectors are orthogonal
But I get the error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-aa2d786e8368> in <module>
8 X_gpu = gpuarray.GPUArray((1000,100), np.float64, order="F") # note that order="F" or a transpose is necessary. fit_transform requires row-major matrices, and column-major is the default
9 X_gpu.set(X) # copy data to gpu
---> 10 T_gpu = pca.fit_transform(X_gpu) # calculate the principal components
11 linalg.dot(T_gpu[:,0], T_gpu[:,1]) # show that the resulting eigenvectors are orthogonal
/opt/conda/lib/python3.6/site-packages/scikit_cuda-0.5.4-py3.6.egg/skcuda/linalg.py in fit_transform(self, X_gpu, transposed_input)
166 raise ValueError("Array must be 2D for PCA")
167 if X_gpu.flags.f_contiguous:
--> 168 raise ValueError("Array must be c_contiguous. Please do NOT instantiate with "
169 "'order=\"F\"'")
170 if transposed_input:
ValueError: Array must be c_contiguous. Please do NOT instantiate with 'order="F"'
And if I remove de order='F', the two vector are not orthogonal, the inner procdict result is always not zero.
Environment
OS platform: nvidia docker image (ubuntu 18.04) running on ubutu 18.04
Python version: Python 3.6.9 :: Anaconda, Inc.
CUDA version: 10.2
PyCUDA version: 2019.1.2
scikit-cuda version: 0.5.4 (cloned august 05, 2020)
The text was updated successfully, but these errors were encountered:
Problem
I'm trying to replicate the PCA example in docs with the following code:
But I get the error:
And if I remove de
order='F'
, the two vector are not orthogonal, the inner procdict result is always not zero.Environment
The text was updated successfully, but these errors were encountered: