MATLAB ismember function with 'rows' option fails on GPU - matlab

When I run the command:
[Lia, Locb] = ismember(gpuArray(Ent_Pair_Pos), gpuArray(Ent_Pair_Dmel), 'rows')
I get this error:
Error using gpuArray/ismember Failed to initialize GPU BLAS library.
The data files can be downloaded from
https://drive.google.com/open?id=1_l51j5wcRSf1gvPxPq-goiIM0nHVCiO7 and
https://drive.google.com/open?id=1T497EmvcsApIUkUWTefFGEvtsPoGnRDE
They can be loaded into MATLAB workspace by running load Ent_Pair_Dmel.txt and load Ent_Pair_Pos.txt.
In addition, here is the output of the gpuDevice command.
CUDADevice with properties:
Name: 'GeForce GTX TITAN X'
Index: 1
ComputeCapability: '5.2'
SupportsDouble: 1
DriverVersion: 9
ToolkitVersion: 7.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 1.2795e+10
AvailableMemory: 1.1801e+10
MultiprocessorCount: 24
ClockRateKHz: 1076000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
I am using MATLAB Version: 9.0.0.341360 (R2016a) on Ubuntu 14.04.
Any idea regarding the error?

Related

How to extract a table from a text file with lots of explanation lines in MATLAB?

I have a text file and want to extract the table inside it in MatLab. The problem is that there are two many lines of explanations before the table. I've tried importdata, readtable and textscan but I did not manage to solve the problem. I did read similar posts, however, they did not work for me. All I want is to get the table inside it.
This is my text file and I just want to get the table:
# Title Segmentation Statistics
#
# generating_program mri_segstats
# cvs_version $Id: mri_segstats.c,v 1.121 2016/05/31 17:27:11 greve Exp $
# cmdline mri_segstats --annot s99060003 lh aparc --i ./ghorbani/s99060003/surf/lh.pial_lgi --sum ./ghorbani/s99060003/stats/lh.aparc.pial_lgi.stats
# sysname Linux
# hostname computational01
# machine x86_64
# user team47
# anatomy_type surface
#
# SUBJECTS_DIR ghorbani/
# subjectname s99060003
# Annot s99060003 lh aparc
# ColorTable /tmp/mri_segstats.tmp.s99060003.lh.107.ctab
# ColorTableTimeStamp 2020/11/11 12:29:40
# InVolFile ./ghorbani/s99060003/surf/lh.pial_lgi
# InVolFileTimeStamp 2020/11/09 13:22:36
# InVolFrame 0
# Only reporting non-empty segmentations
# VertexArea_mm2 0.651303
# TableCol 1 ColHeader Index
# TableCol 1 FieldName Index
# TableCol 1 Units NA
# TableCol 2 ColHeader SegId
# TableCol 2 FieldName Segmentation Id
# TableCol 2 Units NA
# TableCol 3 ColHeader NVertices
# TableCol 3 FieldName Number of Vertices
# TableCol 3 Units unitless
# TableCol 4 ColHeader Area_mm2
# TableCol 4 FieldName Area
# TableCol 4 Units mm^2
# TableCol 5 ColHeader StructName
# TableCol 5 FieldName Structure Name
# TableCol 5 Units NA
# TableCol 6 ColHeader Mean
# TableCol 6 FieldName Intensity Mean
# TableCol 6 Units unknown
# TableCol 7 ColHeader StdDev
# TableCol 7 FieldName Itensity StdDev
# TableCol 7 Units unknown
# TableCol 8 ColHeader Min
# TableCol 8 FieldName Intensity Min
# TableCol 8 Units unknown
# TableCol 9 ColHeader Max
# TableCol 9 FieldName Intensity Max
# TableCol 9 Units unknown
# TableCol 10 ColHeader Range
# TableCol 10 FieldName Intensity Range
# TableCol 10 Units unknown
# NRows 35
# NTableCols 10
# ColHeaders Index SegId NVertices Area_mm2 StructName Mean StdDev Min Max Range
1 1000 8260 5272.3 unknown 2.5699 0.3767 1.7473 3.1269 1.3796
2 1001 1636 1125.1 bankssts 3.7293 0.0772 3.5467 3.9301 0.3833
3 1002 1050 710.4 caudalanteriorcingulate 2.0687 0.0944 1.8839 2.2960 0.4121
4 1003 3758 2416.2 caudalmiddlefrontal 3.3097 0.2763 2.7127 3.8032 1.0905
5 1005 2166 1394.6 cuneus 2.9522 0.1720 2.4722 3.1704 0.6982
6 1006 1174 792.0 entorhinal 2.7577 0.1658 2.4730 3.0749 0.6019
7 1007 5212 3492.8 fusiform 2.7802 0.1668 2.3861 3.0655 0.6794
8 1008 7868 5244.3 inferiorparietal 3.4037 0.2220 2.7239 3.7361 1.0122
9 1009 6358 4246.9 inferiortemporal 2.8457 0.2358 2.3203 3.5561 1.2358
10 1010 1697 1039.9 isthmuscingulate 2.6552 0.1808 2.1455 2.9743 0.8288
11 1011 7550 4798.7 lateraloccipital 2.5837 0.2590 2.2416 3.5063 1.2648
12 1012 4240 2810.9 lateralorbitofrontal 2.7308 0.6746 2.0304 4.6397 2.6094
13 1013 4358 2954.4 lingual 2.8151 0.1788 2.3492 3.0892 0.7401
14 1014 3642 2336.4 medialorbitofrontal 2.2751 0.1566 2.0293 2.7523 0.7230
15 1015 5003 3347.4 middletemporal 3.5771 0.4750 2.5574 4.8942 2.3368
16 1016 1296 853.5 parahippocampal 2.9505 0.0971 2.6101 3.1791 0.5691
17 1017 2216 1350.9 paracentral 2.4485 0.1490 2.1895 2.7342 0.5448
18 1018 2341 1540.7 parsopercularis 4.3045 0.4102 3.6751 4.9626 1.2874
19 1019 1210 824.4 parsorbitalis 3.3446 0.5123 2.6070 4.5994 1.9923
20 1020 2107 1401.6 parstriangularis 4.2211 0.4835 3.0488 4.8220 1.7732
21 1021 1860 1287.3 pericalcarine 2.7804 0.2588 2.3185 3.1067 0.7882
22 1022 7271 4522.0 postcentral 3.5938 0.4878 2.5672 5.1158 2.5486
23 1023 1931 1239.0 posteriorcingulate 2.2056 0.1836 1.8830 2.6753 0.7923
24 1024 8666 5120.9 precentral 3.4961 0.6538 2.2783 5.1111 2.8327
25 1025 5709 3855.1 precuneus 2.9406 0.1734 2.4881 3.2976 0.8096
26 1026 1755 1161.3 rostralanteriorcingulate 2.2062 0.0809 1.9160 2.3647 0.4486
27 1027 9874 6494.3 rostralmiddlefrontal 2.9003 0.4655 2.0864 3.9290 1.8426
28 1028 11653 7628.0 superiorfrontal 2.2950 0.2455 1.9748 3.1270 1.1521
29 1029 9400 6171.7 superiorparietal 3.2156 0.2676 2.6601 3.7812 1.1212
30 1030 5557 3690.8 superiortemporal 4.3597 0.5310 2.5410 5.1207 2.5797
31 1031 6830 4433.7 supramarginal 3.7339 0.2066 3.4023 4.5124 1.1101
32 1032 433 292.9 frontalpole 2.1079 0.0319 2.0224 2.2147 0.1924
33 1033 661 454.8 temporalpole 2.5558 0.0856 2.3724 2.8309 0.4585
34 1034 695 431.5 transversetemporal 4.7385 0.1794 4.3918 5.0519 0.6601
35 1035 3891 2520.8 insula 4.4928 0.7830 2.5227 5.1226 2.6000
You can pass 'HeaderLines' to skip a fixed number of line, when reading file by readtable.
For example to read the file with following contents:
some
extra
lines
come
here
1,2
3,4
, you can run:
readtable('data.txt', 'HeaderLines', 5, 'Delimiter', ',')
It will return:
ans =
Var1 Var2
____ ____
1 2
3 4

Matlab #fmincon error: "Supplied objective function must return a scalar value"

EDIT: To help clarify my question, I'm looking to get a fit to the following data:
I can get a fit using the cftool function, but using a least squares approach doesn't make sense with my binary data. Just to illustrate...
So, my goal is to fit this data using the fmincon function.
ORIGINAL POST:
I have data from a movement control experiment in which participants were timed while they performed a task, and given a score (failure or success) based on their performance. As you might expect, we assume participants will make less errors as they have more time to perform the task.
I'm trying to fit a function to this data using fmincon, but get the error "Error using fmincon (line 609)
Supplied objective function must return a scalar value."
I don't understand a) what this means, or b) how I can fix it.
I provide some sample data and code below. Any help greatly appreciated.
%Example Data:
time = [12.16 11.81 12.32 11.87 12.37 12.51 12.63 12.09 11.25
7.73 8.18 9.49 10.29 8.88 9.46 10.12 9.76 9.99 10.08
7.48 7.88 7.81 6.7 7.68 8.05 8.23 7.84 8.52 7.7
6.26 6.12 6.19 6.49 6.25 6.51 6 6.79 5.89 5.93 3.97 4.91 4.78 4.43
3.82 4.72 4.72 4.31 4.81 4.32 3.62 3.71 4.29 3.46 3.9 3.73 4.15
3.92 3.8 3.4 3.7 2.91 2.84 2.7 2.83 2.46 3.19 3.44 2.67 3.49 2.71
3.17 2.97 2.76 2.71 2.88 2.52 2.86 2.83 2.64 2.02 2.37 2.38
2.53 3.03 2.61 2.59 2.59 2.44 2.73 ]
error = [0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 1 0 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1];
%Code:
% initial parameters - a corresponds to params(1), b corresponds to params(2)
a = 3.0;
b = -0.01;
LL = #(params) 1/1+params(1)*(log(time).^params(2));
LL([a b]);
pOpt = fmincon(LL,[a b],[],[]);
The mistakes comes from the function LL, that returns a number of values equal to the length of time.
To properly use fmincon, you need to have a function that returns only one value.
I believe logistic regression would fit your data and purposes nicely. In that case, why not simply use Matlab's built-in function for multinomial logistic regression?
B = mnrfit(time,error)
Regarding your function LL, are you sure you have entered the function correctly and are not missing a parentheses?
LL = #(params) 1/(1+params(1)*(log(time).^params(2)));
Without the parentheses, you function is equivalent to 1 + a*log(x)^b

gpu slower than cpu for neural networks in matlab

I have the following code:
tic;
H = rand(100, 1000);
F = rand(1, 1000);
net = newff(H, F, [30, 10], { 'tansig' 'tansig'}, 'traingdx', 'learngdm', 'mse');
net.trainParam.epochs = 400;
net.performParam.regularization = 0.05;
net.divideParam.trainRatio = 1;
net.divideParam.valRatio = 0;
net.divideParam.testRatio = 0;
net.trainParam.showWindow = 0;
net.trainParam.showCommandLine = 0;
% net = train(net, H, F, 'useGPU', 'yes', 'showResources', 'yes'); % line 1
net = train(net, H, F, 'showResources', 'yes'); % line 2
toc;
with line 2 uncommented I get
Computing Resources:
GPU device #1, GeForce 800M
Elapsed time is 5.084222 seconds.
and with line 1 uncommented I get
Computing Resources:
MEX2
Elapsed time is 1.870803 seconds.
Why is GPU slower than CPU?
My GPU properties:
CUDADevice with properties:
Name: 'GeForce 800M'
Index: 1
ComputeCapability: '2.1'
SupportsDouble: 1
DriverVersion: 6
ToolkitVersion: 5
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [65535 65535 65535]
SIMDWidth: 32
TotalMemory: 2.1475e+09
FreeMemory: 1.9886e+09
MultiprocessorCount: 1
ClockRateKHz: 1475000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1`

CEPH raw space usage

I can't understand, where my ceph raw space is gone.
cluster 90dc9682-8f2c-4c8e-a589-13898965b974
health HEALTH_WARN 72 pgs backfill; 26 pgs backfill_toofull; 51 pgs backfilling; 141 pgs stuck unclean; 5 requests are blocked > 32 sec; recovery 450170/8427917 objects degraded (5.341%); 5 near full osd(s)
monmap e17: 3 mons at {enc18=192.168.100.40:6789/0,enc24=192.168.100.43:6789/0,enc26=192.168.100.44:6789/0}, election epoch 734, quorum 0,1,2 enc18,enc24,enc26
osdmap e3326: 14 osds: 14 up, 14 in
pgmap v5461448: 1152 pgs, 3 pools, 15252 GB data, 3831 kobjects
31109 GB used, 7974 GB / 39084 GB avail
450170/8427917 objects degraded (5.341%)
18 active+remapped+backfill_toofull
1011 active+clean
64 active+remapped+wait_backfill
8 active+remapped+wait_backfill+backfill_toofull
51 active+remapped+backfilling
recovery io 58806 kB/s, 14 objects/s
OSD tree (each host has 2 OSD):
# id weight type name up/down reweight
-1 36.45 root default
-2 5.44 host enc26
0 2.72 osd.0 up 1
1 2.72 osd.1 up 0.8227
-3 3.71 host enc24
2 0.99 osd.2 up 1
3 2.72 osd.3 up 1
-4 5.46 host enc22
4 2.73 osd.4 up 0.8
5 2.73 osd.5 up 1
-5 5.46 host enc18
6 2.73 osd.6 up 1
7 2.73 osd.7 up 1
-6 5.46 host enc20
9 2.73 osd.9 up 0.8
8 2.73 osd.8 up 1
-7 0 host enc28
-8 5.46 host archives
12 2.73 osd.12 up 1
13 2.73 osd.13 up 1
-9 5.46 host enc27
10 2.73 osd.10 up 1
11 2.73 osd.11 up 1
Real usage:
/dev/rbd0 14T 7.9T 5.5T 59% /mnt/ceph
Pool size:
osd pool default size = 2
Pools:
ceph osd lspools
0 data,1 metadata,2 rbd,
rados df
pool name category KB objects clones degraded unfound rd rd KB wr wr KB
data - 0 0 0 0 0 0 0 0 0
metadata - 0 0 0 0 0 0 0 0 0
rbd - 15993591918 3923880 0 444545 0 82936 1373339 2711424 849398218
total used 32631712348 3923880
total avail 8351008324
total space 40982720672
Raw usage is 4x real usage. As I understand, it must be 2x ?
Yes, it must be 2x. I don't really shure, that the real raw usage is 7.9T. Why do you check this value on mapped disk?
This are my pools:
pool name KB objects clones degraded unfound rd rd KB wr wr KB
admin-pack 7689982 1955 0 0 0 693841 3231750 40068930 353462603
public-cloud 105432663 26561 0 0 0 13001298 638035025 222540884 3740413431
rbdkvm_sata 32624026697 7968550 31783 0 0 4950258575 232374308589 12772302818 278106113879
total used 98289353680 7997066
total avail 34474223648
total space 132763577328
You can see, that the total amount of used space is 3 times more than the used space in the pool rbdkvm_sata (+-).
ceph -s shows the same result too:
pgmap v11303091: 5376 pgs, 3 pools, 31220 GB data, 7809 kobjects
93736 GB used, 32876 GB / 123 TB avail
I don't think you have just one rbd image. The result of "ceph osd lspools" indicated that you had 3 pools and one of pools had name "metadata".(Maybe you were using cephfs). /dev/rbd0 was appeared because you mapped the image but you could have other images also. To list the images you can use "rbd list -p ". You can see the image info with "rbd info -p "

simple gpu computation fails on MATLAB parallel processing toolbox

EDIT: the problem was due to my setup which shadowed the in-built assert function. Thanks to Edric for the tip (see comments below).
I am trying out the gpu capabilities of MATLAB with the example code but receving an error. I am not sure what the error means and how to fix it. The functions I am testing are built-in for gpu as described on MATLAB's help page. Here is as example, but similar error pops up for other functions.
>> x = gpuArray.ones(1,10)
x =
1 1 1 1 1 1 1 1 1 1
>> y = cos(x);
>> gather(y)
Error using assert
Too many input arguments.
Error in parallel.internal.types.Atomic.validateIsScalar (line 133)
Error in parallel.internal.types.Atomic/cType (line 267)
Error in parallel.internal.ptx.ptxEmitter/mangleCprotoEntryLazyEval (line 2614)
Error in parallel.internal.gpu.ptxExpr (line 73)
Here is the gpuDevice output:
>> gpuDevice
ans =
CUDADevice with properties:
Name: 'GeForce GTX 870M'
Index: 1
ComputeCapability: '3.0'
SupportsDouble: 1
DriverVersion: 6.5000
ToolkitVersion: 6
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 6.4425e+09
MultiprocessorCount: 7
ClockRateKHz: 967000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
I will really appreciate any help/pointers.
Thanks
EDIT: I am using MATLAB 2014b