Multiprocessing error

Well, I found a way around the issue.

There are some still some occasional output of errors (pyglet &
Thread 1 “python3” received signal SIGSEGV, Segmentation fault.
0x0000007f54080670 in ?? () from /usr/lib/aarch64-linux-gnu/libGLX.so.0 )

but either way it works.

so here is what I did:

add library path manually into the ~/.bashrc file

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/lib/aarch64-linux-gnu/tegra:/usr/lib/aarch64-linux-gnu/tegra-egl:/usr/lib/aarch64-linux-gnu:/usr/local/lib/aarch64-linux-gnu:/usr/local/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export PATH=/usr/local/cuda/bin:$PATH

downgrade pyglet to version 1.2.4
I tested on 1.3.0 too and it worked, but just to be safe use 1.2.4

for gpu threading refer to
[url]
https://devtalk.nvidia.com/default/topic/1044858/tensorflow-integrate-with-baselines-package-in-openai-gym/?offset=9[/url]
but with numpy==1.16

from there I stole their code and modify it for my purpose. To disable logging just delete logs in the code. I still have a vague understanding of what this does but here:

[code]import os
import platform
import numpy as np
import tensorflow as tf

import gym
import multiprocessing

from baselines import logger
from mpi4py import MPI
from tensorflow.python.client import device_lib

def guess_available_gpus(n_gpus=None):

local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']

def setup_mpi_gpus():
“”"
Set CUDA_VISIBLE_DEVICES using MPI.
“”"
available_gpus = guess_available_gpus()

node_id = platform.node()
nodes_ordered_by_rank = MPI.COMM_WORLD.allgather(node_id)
processes_outranked_on_this_node = [n for n in nodes_ordered_by_rank[:MPI.COMM_WORLD.Get_rank()] if n == node_id]
local_rank = len(processes_outranked_on_this_node)
os.environ['CUDA_VISIBLE_DEVICES'] = str(available_gpus[local_rank])

def guess_available_cpus():
return int(multiprocessing.cpu_count())

def setup_tensorflow_session():
num_cpu = guess_available_cpus()

tf_config = tf.ConfigProto(
    inter_op_parallelism_threads=num_cpu,
    intra_op_parallelism_threads=num_cpu
)
return tf.Session(config=tf_config)

def get_experiment_environment():

setup_mpi_gpus()
logger_context = logger.scoped_configure(dir=None,
                                         format_strs=['stdout', 'log',
                                                      'csv'] if MPI.COMM_WORLD.Get_rank() == 0 else ['log'])
tf_context = setup_tensorflow_session()
return logger_context, tf_context

log, tf_sess = get_experiment_environment()
env = gym.make(‘CartPole-v0’)
env.reset()
with log, tf_sess:
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) # take a random action
[/code]