This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC1867. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an "@" character.
find
# find all files whose name is test.txt in a current directory
find . -name test.txt
# find files using name and ignoring case
find /home -iname test.txt
# find php files using name
find . -type f -name tecmint.php
# find all php files in directory
find . -type f -name "*.php"
# find and remove multiple file
find . -type f -name "*txt" -exec rm -f {} \
# find file according to a certain condition
find . -type f -print | xargs grep "example"
# find empty file
find . -type f -empty
# find empty directory
find . -type d -empty
自动寻找空闲的GPU
def get_gpu_memory_free_map():
"""Get the current gpu usage.
Returns
-------
usage: dict
Keys are device ids as integers.
Values are memory usage as integers in MB.
"""
result = subprocess.check_output(['nvidia-smi', '--query-gpu=memory.free', '--format=csv,nounits,noheader'],
encoding='utf-8')
# Convert lines into a dictionary
gpu_memory_free = [int(x) for x in result.strip().split('\n')]
gpu_memory_free_map = dict(zip(range(len(gpu_memory_free)), gpu_memory_free))
return gpu_memory_free_map
if "CUDA_VISIBLE_DEVICES" in os.environ:
if os.environ["CUDA_VISIBLE_DEVICES"] == "auto":
# 此时必须在外部制定环境变量MEMORY_USAGE
MEMORY_USAGE = int(os.environ["MEMORY_USAGE"])
memory_free_map = get_gpu_memory_free_map()
for i in memory_free_map:
if memory_free_map[i] >= MEMORY_USAGE:
os.environ["CUDA_VISIBLE_DEVICES"] = str(i)
break
if os.environ["CUDA_VISIBLE_DEVICES"] == "auto":
print("GPU MEMORY NOT ENOUGH")
sys.exit(0)
else:
os.environ['CUDA_VISIBLE_DEVICES'] = "-1"