This question already has an answer here:
errors with "segmentation fault occurred "
(1 answer)
Closed 9 years ago.
I have some values written in file 4 which I need to read them again for new calculations but I'm receiving segmentation fault error while I'm running code which this problem occurres in read command "read (4,*) NNrow(I),Niz(I),NNbin(I),Nfi(I),NfiStdDev(I),NfiAvr(I),NMagbin(I),Nzup(I)"
how I can solve this problem?
do j=1,nmax
if (zb(iz,im,j).ne.0) then
call Romberg (dix,dDistCa,zb(iz,im,j),zup(iz)) !COMOVING DISTANCE
Vmax=dix*S !COMOVINF VOLUME
fi=fi+1/Vmax !LUMINOSITY FUNCTION
write(2,'(i5,2x,f9.4,2x,f8.5,2x,3f14.10)')j,magbin,zbin,S,Vmax,dix
endif
enddo
if (Nbin.ge.n_thresh) then
Nrow=Nrow+1
write(4,'(3i7,2x,f25.8,2x,2f20.8,2x,f9.4,2x,f8.5)')Nrow,iz,Nbin,fi,fiStdDev,fiAvr,magbin,zup(iz)
endif
enddo loopmag
rewind(4)
close(4)
write(*,*)Nrow
open(4,file='luminosity_func_I.asc')
allocate (fiStdDev2(Nrow),stat=ok)
allocate (fi_expected(Nrow),stat=ok)
allocate (DFI(Nrow),stat=ok)
allocate (CHISQ(Nrow),stat=ok)
! Ln10=2.3025
A=0.4*2.3025
do I=1,Nrow ! NDATA=NMAX
write(*,*)I
read (4,*) NNrow(I),Niz(I),NNbin(I),Nfi(I),NfiStdDev(I),NfiAvr(I),NMagbin(I),Nzup(I)
fiStdDev2(I)=1/NfiStdDev(I)*NfiStdDev(I)
write(*,*)fiStdDev2(I)
fi_expected(I)=A*fi_star*10**(0.4*(alpha+1)*(M_star-NMagbin(I)))*exp(-10**(0.4*(M_star-NMagbin(I))))
DFI(I)=fi_expected(I)-NFI(I)
CHISQ(I)=DFI(I)*DFI(I)*fiStdDev2(I)
END DO
I am no fortran expert but from my C experience on Linux all I would say is keep debugging until you find the cause, may be one of the variable is not initialized properly and used just like that.
What is I in your code? have you initialized it??
Related
This question already has an answer here:
ioctl giving Invalid Argument
(1 answer)
Closed 5 years ago.
I want to send a file descriptor of a tcp socket from process A to process B, so that process B can create another tcp socket with the same file descriptor.
the idea is exactly the same as passing file descriptors
the key function call is the following:
ioctl(fd, I_SENDFD, fd_to_send);
but it always returns EPERM /* Operation not permitted */
I verified the domain socket file descriptor fd is working, as I could send normal messages through that fd.
I don't know what's wrong. I googled, nobody seems to mention I_SENDFD has permission issue. I tried using "sudo" to run my programs. It still doesn't work.
I have also tried allowing everything for that file descriptorfcntl(fd_to_send, F_SETFL, S_IRWXU|S_IRUSR|S_IWUSR|S_IXUSR|S_IRWXG| S_IRGRP|S_IWGRP|S_IXGRP|S_IRWXO|S_IROTH|S_IWOTH|S_IXOTH);
doesn't work either.
how to fix?
I have found the answer to my question.
Linux doesn't support this, but still keeps the API, which is evil.
for details regarding this issue, see ioctl giving Invalid Argument
here is a workaround solution: Can I share a file descriptor to another process on linux or are they local to the process?
(which I haven't tried)
I am running the following MATLAB code on a system with one GTX 1080 and a K80 (with 2 GPUs)
delete(gcp('nocreate'));
parpool('local',2);
spmd
gpuDevice(labindex+1)
end
reset(gpuDevice(2))
reset(gpuDevice(3))
parfor i=1:100
SingleGPUMatlabCode(i);
end
The code runs for around a second. When I rerun the code after few seconds. I get the message:
Error using parallel.gpu.CUDADevice/reset
An unexpected error occurred during CUDA execution. The
CUDA error was:
unknown error
Error in CreateDictionary
reset(gpuDevice(2))
I tried increasing TdrDelay, but it did not help.
Something in your GPU code is causing an error on the device. Because the code is running asynchronously, this error is not picked up until the next synchronisation point, which is when you run the code again. I would need to see the contents of SingleGPUMatlabCode to know what that error might be. Perhaps there's an allocation failure or an out of bounds access. Errors that aren't correctly handled will get converted to 'unknown error' at the next CUDA operation.
Try adding wait(gpuDevice) inside the loop to identify when the error is occurring.
If either device 2 or 3 are the GTX1080, you may have discovered an issue with MATLAB's restricted support for the Pascal architecture. See https://www.mathworks.com/matlabcentral/answers/309235-can-i-use-my-nvidia-pascal-architecture-gpu-with-matlab-for-gpu-computing
If this is caused by the Windows timeout, you would see a several second screen blackout.
I asked today a question about Parallel Computing with Matlab-Simulink. Since my earlier question is a bit messy and there are a lot of things in the code which doesnt really belong to the problem.
My problem is
I want to simulate something in a parfor-Loop, while my Simulink-Simulation uses the "From Workspace" block to integrate the needed Data from the workspace into the simulation. For some reason it doesnt work.
My code looks as follows:
load DemoData
path = pwd;
apool = gcp('nocreate');
if isempty(apool)
apool = parpool('local');
end
parfor k = 1 : 2
load_system(strcat(path,'\DemoMDL'))
set_param('DemoMDL/Mask', 'DataInput', 'DemoData')
SimOut(k) = sim('DemoMDL')
end
delete(apool);
My simulation looks as follows
The DemoData-File is just a zeros(100,20)-Matrix. It's an example for Data.
Now if I simulate the Script following error message occures:
Errors
Error using DemoScript (line 9)
Error evaluating parameter 'DataInput' in 'DemoMDL/Mask'
Caused by:
Error using parallel_function>make_general_channel/channel_general (line 907)
Error evaluating parameter 'DataInput' in 'DemoMDL/Mask'
Error using parallel_function>make_general_channel/channel_general (line 907)
Undefined function or variable 'DemoData'.
Now do you have an idea why this happens??
The strange thing is, that if I try to acces the 'DemoData' inside the parfor-Loop it works. For excample with that code:
load DemoData
path = pwd;
apool = gcp('nocreate');
if isempty(apool)
apool = parpool('local');
end
parfor k = 1 : 2
load_system(strcat(path,'\DemoMDL'))
set_param('DemoMDL/Mask', 'DataInput', 'DemoData')
fprintf(num2str(DemoData))
end
delete(apool);
Thats my output without simulating and displaying the Data
'>>'DemoScript
00000000000000000 .....
Thanks a lot. That's the original question with a lot more (unnecessary) details:
EarlierQuestion
I suspect the issue is that when MATLAB is pre-processing the parfor loop to determine what variables need to be passed to the workers it does not know what DemoData is. In your first example it's just a string, so no data gets sent over. In your second example it explicitly knows about the variable and hence does pass it over.
You could try either using the Model Workspace, or perhaps just inserting the line
DemoData = DemoData;
in the parfor loop code.
Your error is because workers did not have access to DemoData in the client workspace.
When running parallel simulations with Simulink it would be easier to manage data from workspace if you move them to model workspace. Then each worker can access this data from its model workspace. You can load a MAT file or write MATLAB code to initialize data in model workspace. You can access model workspace using the Simulink model menu View->Model Explorer->Model Workspace.
Also see documentation at http://www.mathworks.com/help/simulink/ug/running-parallel-simulations.html that talks about "Resolving workspace access issues".
You can also move the line
load DemoData
to within the parfor loop. Doing this, you assure that the data will be available in each worker base workspace, wich is accessible to the model, instead of the client workspace.
I am running Matlab from a Fortran function and am having a persistent problem that I am getting the error
*** glibc detected *** /matlab/8.5/bin/glnxa64/MATLAB: double free or corruption (out): 0x00002b11a9a86f20 ***
I am not sure which line the error is occuring on but I have quite a few that follow this pattern
MLVar = engGetVariable(ep, 'un')
call mxCopyPtrToReal8(mxGetPr(MLVar), SurfaceField, BoundaryCells)
call mxDestroyArray(MLVar)
and I go through this function between 1 and 100s of times before this error occurs.
It looks like here they said to use mxDestroyArray which I'm already using.
Any advise?
The problem ended up being completely unrelated. I am submitting this to a remote cluster using a submission script, and I used a "V" option and then when I closed my terminal connection with Matlab forced close.
I have used the vlfeat toolbox and the vl_sift, lot of times with no problem. I decided to use it in Matlab R2009a, with ubuntu 14.04. This is the error I get while running vl_setup()
??? XML-file failed validation against schema located in:
/home/tonystark/Matlab_prg/sys/namespace/info/v1/info.xsd
XML-file name:
/home/tonystark/freelancing/Content_based_image_retrieval/code/new_code/vlfeat-0.9.18/toolbox/info.xml
To retest the XML-file against the schema, call the following java method:
com.mathworks.xml.XMLValidator.validate(...
'/home/tonystark/freelancing/Content_based_image_retrieval/code/new_code/vlfeat-0.9.18/toolbox/info.xml',...
'/home/tonystark/Matlab_prg/sys/namespace/info/v1/info.xsd', true)
Errors:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found
starting with element 'help_contents_icon'. One of '{product_name_ends_with_type,
help_addon, preference_panel, dialogpref_registrar, project_plugin, state_item, list}'
is expected.
But when I run the same code again, the error doesn't come and the code vl_setup compiles, but no output displayed
And when I run this sample code
clc;
close all;
clear all;
I1 = imread('/home/tonystark/freelancing/Content_based_image_retrieval/Dataset/all_souls_000140.jpg');
I2 = imread('/home/tonystark/freelancing/Content_based_image_retrieval/Dataset/all_souls_000146.jpg');
[f1 d1] = vl_sift(single(rgb2gray(I1)));
[f2 d2] = vl_sift(single(rgb2gray(I2)));
matlab crashes with the following error on the terminal
*** invalid %N$ use detected ***
Aborted (core dumped)
I am stuck here for quite some time without any specific direction. If somebody can point me in the right direction or solve this, it would be of great help! Your help is much appreciated.
UPDATE 1
The readme file of vlfeat says it requires matlab 2009b min, for the toolbox to work. could that be a reason?