当我尝试使用shape.eval()打印一个共享变量的形状时,我得到了一个“无法分配内存”的错误。但是当我将其转换为numpy数组(从而将其移动到CPU)时,我不仅可以得到它的形状,还可以得到数组本身。看看下面它在pdb中停止的地方,数据已经加载到CPU/RAM中,然后我尝试打印p1的形状:
(Pdb) p1
W
(Pdb) type(p1)
<class 'theano.sandbox.cuda.var.CudaNdarraySharedVariable'>
(Pdb) p1.shape.eval()
Problem occurred during compila
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
try {
Thread.sleep(10000);
} catch(InterruptedException e) {
/* ignored */
}
}
}
下面是我运行这个小程序时top所说的话:
PID USER PR NI
关于pthread_attr_setstacksize 的手册页
A thread's stack size is fixed at the time of thread creation. Only the main thread can dynamically grow its stack.
我对linux线程的理解是,主线程堆栈的大小仅限于主线程创建上的ulimit -s值。虽然它可以根据堆栈使用的需要映射到virt,但其大小不再增长。
动态增长在这里意味着什么?这是否意味着主线程堆栈的大小可以超过ulimit -s
我在维基百科上读到了关于mmap的内容,并尝试了这个示例。我和gcc一起编译了这个程序,并在上面运行了valgrind。
下面是valgrind的输出:
# valgrind a.out
==7018== Memcheck, a memory error detector
==7018== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==7018== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==7018== C
我使用Peano-Hilbert数据排序(c++ 4.9,Linux64x)来合并动态分配的内存。为了进行控制,我试图在内存中可视化实际的数据分布。为此,我将指向数据的指针转换为整数,如下所示
unsigned long int address = *(unsigned long int*)(&pointer);
然后把它们绘制成二维地图。它在大多数情况下都能正常工作,但有时我得到的值超过了现有内存,例如140170747903888,这相当于127TB的移位,而我只有16 GB的内存。搞什么鬼?