在python3.6的pycharm中,在一段检测进程占用内存情况的代码中,由于是开源代码,它指定的路径是Linux系统里的'/proc/{}/status'
而我没有这样的路径,我应该怎么修改
报错如图
D:\Anaconda\anaconda3\envs\pytorch\python.exe D:\GNN_test1\GNN-GCP-master\GNN-GCP-master\neurosat\neurosat_train.py
Traceback (most recent call last):
File "D:\GNN_test1\GNN-GCP-master\GNN-GCP-master\neurosat\neurosat_train.py", line 29, in <module>
print( "{timestamp}\t{memory}\tBuilding model ...".format( timestamp = timestamp(), memory = memory_usage() ) )
File "D:\GNN_test1\GNN-GCP-master\GNN-GCP-master\neurosat\util.py", line 11, in memory_usage
s = next( line for line in open( '/proc/{}/status'.format( pid ) ).read().splitlines() if line.startswith( 'VmSize' ) ).split()
FileNotFoundError: [Errno 2] No such file or directory: '/proc/11612/status'
Process finished with exit code 1
代码片段是这样
def memory_usage():
pid=os.getpid()
s = next( line for line in open( '/proc/{}/status'.format( pid ) ).read().splitlines() if line.startswith( 'VmSize' ) ).split()
return "{} {}".format( s[-2], s[-1] )
#end memory_usage
我大概了解是路径 '/proc/{}/status'有问题,但是不知道应该怎么修改,希望得到解决方法